+1-888-365-2779
Try Now
More in this section

Forums / Bugs & Issues / Cannot insert duplicate key row

Cannot insert duplicate key row

12 posts, 0 answered
  1. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    19 Apr 2011
    Link to this post
    Anyone else getting this?  Two attempted upgrades, both hit this same error...

    I update with the project manager, download the new .lic file (overwrite it), rebuild and then load up the site.  Fails every time it seems.


    Cannot insert duplicate key row in object 'sitefinitysteve.sf_schema_vrsns' with unique index 'idx_sf_schema_vrsns'.
    The statement has been terminated.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: Telerik.OpenAccess.RT.sql.SQLException: Cannot insert duplicate key row in object 'sitefinitysteve.sf_schema_vrsns' with unique index 'idx_sf_schema_vrsns'.
    The statement has been terminated.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:

    [SQLException: Cannot insert duplicate key row in object 'sitefinitysteve.sf_schema_vrsns' with unique index 'idx_sf_schema_vrsns'.
    The statement has been terminated.]
       Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.execute() +919
       OpenAccessRuntime.Relational.conn.PooledPreparedStatement.execute() +119
       OpenAccessRuntime.Relational.RelationalStorageManager.generateInserts(NewObjectOID oid, Int32 index, ClassMetaData cmd, PersistGraph graph, Int32[] fieldNos, CharBuf s, Object[] oidData, IntArray toUpdateIndexes) +2477
    
    [DuplicateKeyException: Insert of '255938952-70e26627-cf18-4033-95e5-61a9ab8c8bf6' failed: Telerik.OpenAccess.RT.sql.SQLException: Cannot insert duplicate key row in object 'sitefinitysteve.sf_schema_vrsns' with unique index 'idx_sf_schema_vrsns'.
    The statement has been terminated.
       at Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.execute()
       at OpenAccessRuntime.Relational.conn.PooledPreparedStatement.execute()
       at OpenAccessRuntime.Relational.RelationalStorageManager.generateInserts(NewObjectOID oid, Int32 index, ClassMetaData cmd, PersistGraph graph, Int32[] fieldNos, CharBuf s, Object[] oidData, IntArray toUpdateIndexes)
    INSERT INTO [sf_schema_vrsns] ([id], [app_name], [assembly], [connection_id], [cultures], [last_upgrade_date], [meta_data_changed], [module_name], [previous_version_number], [version_number]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
    (set event logging to all to see parameter values)]
       DynamicModule.ns.Wrapped_OpenAccessMetaDataProvider_68c0e8931b5242e1b7a928cf04ee1d3f.Initialize(String providerName, NameValueCollection config, Type managerType) +405
       Telerik.Sitefinity.Data.ManagerBase`1.InstantiateProvider(IDataProviderSettings providerSettings, Type providerType, ExceptionPolicyName policy, ManagerBase`1 manager) +2211
       Telerik.Sitefinity.Data.ManagerBase`1.InstantiateProvider(IDataProviderSettings providerSettings, ExceptionPolicyName policy, ManagerBase`1 manager) +74
       Telerik.Sitefinity.Data.ManagerBase`1.SetProvider(String providerName, String transactionName) +214
    
    [TargetInvocationException: Exception has been thrown by the target of an invocation.]
       System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
       System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache) +117
       System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache) +247
       System.Activator.CreateInstance() +88
       Telerik.Sitefinity.Data.ManagerBase`1.GetManager(String providerName, String transactionName) +115
       Telerik.Sitefinity.Services.SystemManager.Initialize() +142
       Telerik.Sitefinity.Abstractions.Bootstrapper.RegisterRoutes(RouteCollection routes) +243
       Telerik.Sitefinity.Abstractions.Bootstrapper.Bootstrap() +338
       Telerik.Sitefinity.Web.SitefinityHttpModule.Init(HttpApplication context) +30
       System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +546
       System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +325
       System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +407
       System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +375
    
    [HttpException (0x80004005): Exception has been thrown by the target of an invocation.]
       System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +11529072
       System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +141
       System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +4784373
    
  2. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    19 Apr 2011
    Link to this post
    Seems like it keeps trying to insert records into here: sf_schema_vrsns

    Heres a trace

    http://dl.dropbox.com/u/3234184/trace.zip
  3. Jeff
    Jeff avatar
    6 posts
    Registered:
    01 Jun 2010
    19 Apr 2011
    Link to this post
    I had the same issue, save my error referenced "dbo" instead of "sitefinitysteve."  What resolved it for me was removing the projectName attribute and its value from the ProjectConfig.config.
  4. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    19 Apr 2011
    Link to this post
    Did you do something after that by any chance?

    Didnt seem to work here
  5. Jeff
    Jeff avatar
    6 posts
    Registered:
    01 Jun 2010
    19 Apr 2011
    Link to this post
    Sorry, I don't remember having to do anything else.  Although, we haven't gone live with the site yet, so I had the liberty of restarting with a fresh database and new set of config files.  I wouldn't go crazy on my opinion as someone who's just recently started developing for 4.0, but I'd guess there's something else in one of your config files that's causing problems.
  6. Lubomir Velkov
    Lubomir Velkov avatar
    688 posts
    Registered:
    03 Nov 2014
    22 Apr 2011
    Link to this post
    Hi Jeff,

    I opened the trace and I see which statement fails. There is a UNIQUE index on 3 fields in the sf_schema_vrsns table - app_name, module_name and connection_id. You could send us your project so we could investigate the issue more thoroughly, but meanwhile I could suggest you do the following - after the upgrade take note of the row that has

    app_name = NULL and module_name = 'Sitefinity' (it should be only one)

    temporary drop the index and load this site - this should add a second row with similar parameters, then delete the first row. I'm not sure this will work but it seems our upgrade scripts execute an INSERT instead of UPDATE statement when updating this particular row in the database, which causes the constraint error.

    Greetings,
    Lubomir Velkov
    the Telerik team

  7. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    22 Apr 2011
    Link to this post
    @Lubomir

    Is this something that will be fixed for 4.1 SP1?  If that's the case I cant wait on updating this site...knowing that you guys are going to fix the issue (I say going assuming it wont miss SP1 due to other priorities ;)

    It's shared hosting and the DB is marked annoyingly against a schema, and they're using an older DB version than I am so I cant edit everything here and just give them the DB to re-attach.
  8. Styrmir Ingi Bjarnason
    Styrmir Ingi Bjarnason avatar
    1 posts
    Registered:
    09 Nov 2009
    26 Apr 2011
    Link to this post
    I got this issue when upgrading from 4.0, my way of solving this was simply to open up the administrator area (xxx.xx/sitefinity) and logging in, it gave me a screen of where I had to re-validate my license, I entered my information and voilah, then I simply logged in with my account and I got in. After doing this I did not get any SQL error on the actual site, so yeah thats how it worked for me :) 
  9. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    27 Apr 2011
    Link to this post
    Yeah sadly I can't even GET to the admin area...
  10. Lubomir Velkov
    Lubomir Velkov avatar
    688 posts
    Registered:
    03 Nov 2014
    28 Apr 2011
    Link to this post
    Hello Steve,

    We tracked down the problem and it was solved. It will be available for the upcoming Service Release.

    Best wishes,
    Lubomir Velkov
    the Telerik team

  11. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    05 May 2011
    Link to this post
    @Lubomir

    Sadly I can assure you it did not make its way into the latest internal release as I still get this error (now on a new project)

    Can you tell me the fix please?

    I wiped the row out of "sf_schema_vrsns", now it's endlessly inserting rows with version 0\0
  12. Lubomir Velkov
    Lubomir Velkov avatar
    688 posts
    Registered:
    03 Nov 2014
    05 May 2011
    Link to this post
    Hello Steve,

    I apologize for any misunderstanding that might have happened - I mean the SP release due by the end of the next week. You were checking the internal build release where this fix was not checked in.

    All the best,
    Lubomir Velkov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
12 posts, 0 answered