Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • John 3 posts 84 karma points
    Jan 05, 2021 @ 11:23
    John
    0

    AppDomain synchronization and SQlMainDomLock - ReadOnly DB Issue

    Hi,

    I’m rebuilding a large Azure-based solution from v7 to v8 which runs across two Azure regions. The first region has two Web Apps – a BackOffice (Master) instance and a scalable FrontEnd (Replica) instance, both connected to the same Umbraco database. The second region has a scalable FrontEnd (Replica) instance connected to a read-only database which is geo-replicated from the first to the second region. Traffic to the public FrontEnds is balanced across the two regions using Traffic Manager. The Master/Replica roles are set explicitly. This has worked very well under v7.x as Replica instances don’t need to write to the DB.

    When implementing v8.8.0 onto an equivalent infrastructure and configuration, the FrontEnd in the second region will not run as it is trying to write to the read-only DB.

    I know there have been some issues around AppDomain synchronisation, and we’ve configured the different role instances as described for v8.6.4+ at: https://our.umbraco.com/documentation/getting-started/setup/server-setup/load-balancing/azure-web-apps

    From the narrative, it looks as if a database locking mechanism has been introduced, and I wonder if the side affect of this is that:

    • Replica instances now have to write to the DB (which they didn’t
      before), or
    • if this is an unintended bug that was introduced by the new locking mechanism, or
    • the documentation for v8.6.4+ is not correct.

    When the role is set as Replica and web.config contains <add key="Umbraco.Core.MainDom.Lock" value="SqlMainDomLock" /> it tries to write the following on startup:

     - exec sp_executesql N'UPDATE umbracoLock WITH (REPEATABLEREAD) SET
       value = (CASE WHEN (value=1) THEN -1 ELSE 1 END) WHERE id=@0',N'@0
       int',@0=-1000 
     - exec sp_executesql N'UPDATE [umbracoKeyValue] SET
       [value] = @0, [updated] = @1 WHERE [key] = @2',N'@0 nvarchar(4000),@1
       datetime,@2
       nvarchar(4000)',@0=N'fd33b90c-c0f1-4d34-88b9-8c7aa5dad5a9',@1='2021-01-05
       10:57:25.977',@2=N'Umbraco.Core.Runtime.SqlMainDom-ccfdae47576e05f046d6abdf24f0206094750d23'
    

    and every second runs

     - exec sp_executesql N'SELECT value FROM umbracoLock WITH
       (REPEATABLEREAD) WHERE id=@0',N'@0 int',@0=-1000 
     - exec sp_executesql
       N'SELECT * FROM umbracoKeyValue WHERE [key] = @0',N'@0
       nvarchar(4000)',@0=N'Umbraco.Core.Runtime.SqlMainDom-ccfdae47576e05f046d6abdf24f0206094750d23'
    

    When the role is set as Replica and web.config does NOT contain a value for key "Umbraco.Core.MainDom.Lock" no write occurs, but I don’t know if this would re-introduce the AppDomain synchronisation errors that SqlMainDomLock is addressing.

    Any advice on how the Replicas should be configured would be appreciated. I can raise a bug ticket if agreed.

    Thanks, John

  • John 3 posts 84 karma points
    Jun 17, 2021 @ 09:00
    John
    0

    Just to close the loop on this in case others come across this thread.

    Umbraco documentation has been updated to cover this scenario (copied from https://our.umbraco.com/Documentation/Fundamentals/Setup/Server-Setup/Load-Balancing/flexible-advanced#front-end-servers---read-only-database-access):

    If using SqlMainDomLock on Azure WebApps then write-permissions are required for the following tables for all server roles including 'Replica'.

    • umbracoLock
    • umbracoKeyValue

    SQL Server Replica databases cannot be used as they are read-only without replacing the default MainDomLock with a custom provider.

Please Sign in or register to post replies

Write your reply to:

Draft