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.
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.
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:
before), or
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:and every second runs
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
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):
is working on a reply...