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

Forums / Bugs & Issues / SQL Error on Deploying Sitefinity 5.1 to Shared Hosting

SQL Error on Deploying Sitefinity 5.1 to Shared Hosting

4 posts, 0 answered
  1. John
    John avatar
    7 posts
    Registered:
    11 Oct 2012
    06 Dec 2012
    Link to this post
    Hi folks,

    I've run into an error that has stymied me the past day.  I am deploying Sitefinity 5.1.3450.0 to Shared Hosting (Adhost - a reliable provider here in Seattle).  This error does not occur on my development machine.

    The only changes I have made to the site was adding placeholder pages.  I've not added or changed templates, or anything else.  Other than the pages I've added this is a default empty database.

    To deploy the database I gave Adhost the .mdf file which they then attached to the separate SQL server and added the users needed to access the db.  I added a machine key and connection string to the Web.config per the instructions here:

    http://www.sitefinity.com/documentation/documentationarticles/installation-and-administration-guide/deployment/deploying-sitefinity-projects-to-shared-hosting

    The site throws a SQL error upon resolving the url about trying to insert a duplicate key.  The page template it references is one of the default temppaltes.

    Any ideas?  I am facing having reinstall and redeploy.

    Server Error in '/' Application.

    Violation of PRIMARY KEY constraint
    'pk_sf_page_templates'. Cannot insert duplicate key in object
    'dbo.sf_page_templates'. The duplicate key value is
    (f669d9a7-009d-4d83-bbbb-000000000004).
    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:
    Violation of PRIMARY KEY constraint 'pk_sf_page_templates'. Cannot
    insert duplicate key in object 'dbo.sf_page_templates'. The duplicate
    key value is (f669d9a7-009d-4d83-bbbb-000000000004).
    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: Violation of PRIMARY KEY constraint 'pk_sf_page_templates'. Cannot insert duplicate key in object 'dbo.sf_page_templates'. The duplicate key value is (f669d9a7-009d-4d83-bbbb-000000000004).
    The statement has been terminated.]
    Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.execute() +344
    OpenAccessRuntime.Relational.conn.PooledPreparedStatement.execute() +77
    OpenAccessRuntime.Relational.RelationalStorageManager.generateInserts(NewObjectOID oid, Int32 index, ClassMetaData cmd, PersistGraph graph, Int32[] fieldNos, CharBuf s, Object[] oidData, IntArray toUpdateIndexes) +1833

    [DuplicateKeyException: Insert of '1712689138-f669d9a7-009d-4d83-bbbb-000000000004' failed: Telerik.OpenAccess.RT.sql.SQLException: Violation of PRIMARY KEY constraint 'pk_sf_page_templates'. Cannot insert duplicate key in object 'dbo.sf_page_templates'. The duplicate key value is (f669d9a7-009d-4d83-bbbb-000000000004).
    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_page_templates] ([description_], [keywords_], [title_], [app_name], [buffer_output], [cache_duration], [cache_output], [can_inherit_permissions], [category], [culture], [enable_event_validation], [enable_session_state], [enable_theming], [enable_view_state], [enable_view_state_mac], [error_page], [framework], [id], [include_script_manger], [inherits_permissions], [ky], [last_control_id], [last_modified], [locked_by], [maintain_scroll], [master_page], [nme], [ordinal], [ownr], [prent_template_id], [require_ssl], [response_encoding], [show_in_navigation], [sliding_expiration], [smart_navigation], [theme], [ui_culture], [validate_request], [vrsion], [view_state_encryption], [voa_version]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
    (set event logging to all to see parameter values)]
    DynamicModule.ns.Wrapped_OpenAccessPageProvider_cd7bfea38ca6418ca76807e2c6280988.GetSecurityRoot() +162
    Telerik.Sitefinity.Data.ManagerBase`1.GetSecurityRoot() +30
    Telerik.Sitefinity.Abstractions.SiteInitializer.CreateBackendRoot() +786
    Telerik.Sitefinity.Abstractions.SiteInitializer.InstallDefaults() +54
    Telerik.Sitefinity.Services.SystemManager.Initialize() +315
    Telerik.Sitefinity.Abstractions.Bootstrapper.RegisterRoutes() +621
    Telerik.Sitefinity.Abstractions.Bootstrapper.Bootstrap() +281
    Telerik.Sitefinity.Web.SitefinityHttpModule.Init(HttpApplication context) +116
    System.Web.Routing.UrlRoutingModule.System.Web.IHttpModule.Init(HttpApplication application) +10
    System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +517
    System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +194
    System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +339
    System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +253

    [HttpException (0x80004005): Insert of '1712689138-f669d9a7-009d-4d83-bbbb-000000000004' failed: Telerik.OpenAccess.RT.sql.SQLException: Violation of PRIMARY KEY constraint 'pk_sf_page_templates'. Cannot insert duplicate key in object 'dbo.sf_page_templates'. The duplicate key value is (f669d9a7-009d-4d83-bbbb-000000000004).
    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_page_templates] ([description_], [keywords_], [title_], [app_name], [buffer_output], [cache_duration], [cache_output], [can_inherit_permissions], [category], [culture], [enable_event_validation], [enable_session_state], [enable_theming], [enable_view_state], [enable_view_state_mac], [error_page], [framework], [id], [include_script_manger], [inherits_permissions], [ky], [last_control_id], [last_modified], [locked_by], [maintain_scroll], [master_page], [nme], [ordinal], [ownr], [prent_template_id], [require_ssl], [response_encoding], [show_in_navigation], [sliding_expiration], [smart_navigation], [theme], [ui_culture], [validate_request], [vrsion], [view_state_encryption], [voa_version]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
    (set event logging to all to see parameter values)]
    System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9088636
    System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +97
    System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +256

    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272




  2. Victor Velev
    Victor Velev avatar
    1345 posts
    Registered:
    06 Jul 2015
    11 Dec 2012
    Link to this post
    Hello John,

    Can you elaborate a bit more on the the steps you took to deploy your project as the error suggests that there are some problems trying to insert duplicate keys in a object of the database? Have you used the publish functionality of Visual Studio?

    If you are not getting an error on development can you try uploading the files again and make sure all transfers complete at 100%, as there might be some problems with the configurations and the DLLs not being uploaded correctly.

    Also, when choosing a hosting provider I would suggest to check our hosting partners page:

    http://www.sitefinity.com/partners/hosting-partners.aspx


    Greetings,
    Victor Velev
    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
  3. John
    John avatar
    7 posts
    Registered:
    11 Oct 2012
    11 Dec 2012
    Link to this post
    Hi Victor,

    Here are the steps I took:

    - Created a new project in Sitefinity Project manager, then browsed to the site on localhost.
    - Logged in, created the admin user, and created a site structure by creating pages.  I didn't add anything else to the site.
    - Opened the site in VS2010 (again starting in the project manager) and yes, published the site to a separate file folder.
    - I added a connection string to the hosts SQL Server and machine key to the resulting web.config.
    - Then I FTP'd up the site to the host, along with the .mdf.
    - Adhost (the hosting company) attached the db to the SQL Server (we don't have file access, but we do have SSMS access).
    - Worked through a missing assembly issue with Microsoft.WindowsAzure.Diagnostics by copying up the DLLs from the local dev version.
    - Tried to access the site and received

    What I don't understand is why the site is trying to recreate the standard templates?  Is there a trigger for that?

    Thanks for the list of hosting companies.  We've been working with Adhost for 6 years and they are really pretty good.  Our client has the relationship with them, so it would be an issue to switch at this point and since this is a SQL primary key violation the hosting environment is not likely the issue.

    thanks
    John
  4. Victor Velev
    Victor Velev avatar
    1345 posts
    Registered:
    06 Jul 2015
    14 Dec 2012
    Link to this post
    Hello John,

    Thank you for providing the additional information about the steps you took to deploy your website. I have few notes based on your data.

    - We strongly suggest not to use the publish functionality of Visual Studio, as we encountered other cases, in which client reported their websites not being published correctly when using the built - in publish option of Visual Studio.

    When deploying to a web server, we suggest to copy the files manually to the new destination.

    - Regarding the error:

    By default most of the tables we use Guids for unique identifiers and primary keys. For those tables it is impossible to generate two and the same Guids, unless the Guid is specifically set beforehande. There are however 8 tables that do not use Guid but use auto incremented identifiers for primary keys, and those are managed by OpenAccess. there is a table voa_keygen which holds the latest used keys, so that when inserting values the ORM does not generate duplicate IDs.

    However if for example you are transferring data from one db to another using SQL script and you do not transfer the data from this table, you risk having this exception. Since the exception is generated when your database is being attached, I assume that the problem is actually coming from the actual SQL setup - most probably the system is trying to recreate the tables and the data, due to a missing configuration file or improper login / user in the SQL database.

    Kind regards,
    Victor Velev
    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
4 posts, 0 answered