Open Abrissirba opened 1 year ago
Hi there @Abrissirba!
Firstly, a big thank you for raising this issue. Every piece of feedback we receive helps us to make Umbraco better.
We really appreciate your patience while we wait for our team to have a look at this but we wanted to let you know that we see this and share with you the plan for what comes next.
We wish we could work with everyone directly and assess your issue immediately but we're in the fortunate position of having lots of contributions to work with and only a few humans who are able to do it. We are making progress though and in the meantime, we will keep you in the loop and let you know when we have any questions.
Thanks, from your friendly Umbraco GitHub bot :robot: :slightly_smiling_face:
I just wanted to affirm that we are also encountering the same challenges.
Hey @Abrissirba & @strudland, sorry for the late reply, this one has seemed to have slipped trough the cracks.
I will speak to the team on how we are going to approach this one and get back to you asap.
✅ Reproduced in v10 (10.1.0) ✅ Reproduced in v10 (10.7.0)
Reproduction did not result in deadlocks but the local solution complexly crashing, this might be because of sqlLite, will investigate further if needed No deadlock errors but the amount of total requests went from 9452 (for just requesting the login page) to 614 passed 126 failed for when logging in then login out members with the following k9 stage configuration. This results in 45 succeeded and 123 failed login attempts.
stages: [
{ duration: '10s', target: 10 },
{ duration: '10s', target: 30 },
{ duration: '10s', target: 50 },
{ duration: '60s', target: 100 },
{ duration: '20s', target: 200 },
{ duration: '10s', target: 30 },
{ duration: '10s', target: 10 },
],
full test code and setup instructions included in 13768.zip
✅ Reproduced in v11 (11.6.0) v11results.zip (zip has the wrong name)
✅ Reproduced in v12 (12.2.0)
Finally was able to capture an error on SqlLite, but it doesn't show in the logs as the app kills itself
Umbraco.Cms.Core.DistributedLocking.Exceptions.DistributedWriteLockTimeoutException: Failed to acquire write lock for id: -341.
at Umbraco.Cms.Persistence.Sqlite.Services.SqliteDistributedLockingMechanism.SqliteDistributedLock.ObtainWriteLock() in C:\Repos\Umbraco-CMS-V12\src\Umbraco.Cms.Persistence.Sqlite\Services\SqliteDistributedLockingMechanism.cs:line 175
at Umbraco.Cms.Persistence.Sqlite.Services.SqliteDistributedLockingMechanism.SqliteDistributedLock..ctor(SqliteDistributedLockingMechanism parent, Int32 lockId, DistributedLockType lockType, TimeSpan timeout) in C:\Repos\Umbraco-CMS-V12\src\Umbr
aco.Cms.Persistence.Sqlite\Services\SqliteDistributedLockingMechanism.cs:line 82
at Umbraco.Cms.Persistence.Sqlite.Services.SqliteDistributedLockingMechanism.WriteLock(Int32 lockId, Nullable`1 obtainLockTimeout) in C:\Repos\Umbraco-CMS-V12\src\Umbraco.Cms.Persistence.Sqlite\Services\SqliteDistributedLockingMechanism.cs:line
51
at Umbraco.Cms.Core.Scoping.LockingMechanism.ObtainWriteLock(Int32 lockId, Nullable`1 timeout) in C:\Repos\Umbraco-CMS-V12\src\Umbraco.Core\Scoping\LockingMechanism.cs:line 98
at Umbraco.Cms.Core.Scoping.LockingMechanism.LockInner(Guid instanceId, Dictionary`2& locks, HashSet`1& locksSet, Action`2 obtainLock, Nullable`1 timeout, Int32 lockId) in C:\Repos\Umbraco-CMS-V12\src\Umbraco.Core\Scoping\LockingMechanism.cs:lin
e 172
at Umbraco.Cms.Core.Scoping.LockingMechanism.EagerWriteLockInner(Guid instanceId, Nullable`1 timeout, Int32[] lockIds) in C:\Repos\Umbraco-CMS-V12\src\Umbraco.Core\Scoping\LockingMechanism.cs:line 74
at Umbraco.Cms.Core.Scoping.LockingMechanism.EagerWriteLock(Guid instanceId, Nullable`1 timeout, Int32[] lockIds) in C:\Repos\Umbraco-CMS-V12\src\Umbraco.Core\Scoping\LockingMechanism.cs:line 54
at Umbraco.Cms.Core.Scoping.CoreScope.EagerWriteLock(Int32[] lockIds) in C:\Repos\Umbraco-CMS-V12\src\Umbraco.Core\Scoping\CoreScope.cs:line 202
at Umbraco.Cms.Infrastructure.HostedServices.ScheduledPublishing.PerformExecuteAsync(Object state) in C:\Repos\Umbraco-CMS-V12\src\Umbraco.Infrastructure\HostedServices\ScheduledPublishing.cs:line 116
reproduced in 12.3.3
I've seen the Failed to acquire write lock for id: -341.
error a few times while doing large content deployments/publishes on SQLite as well. I believe the issue is caused by the fact SQLite can only have a single concurrent writable transaction, as mentioned in this comment:
Because the ScheduledPublishing
background job takes an eager write lock on Constants.Locks.ScheduledPublishing
, it will completely block any other write transaction or needs to wait until the current write transaction has completed, with the potential to timeout either transaction.
It probably doesn't help that the scope in this background job uses autoComplete: true
since it got refactored in v12:
https://github.com/umbraco/Umbraco-CMS/blob/c30ffa9ac3ae9c12508242855c63208567c55eb9/src/Umbraco.Infrastructure/BackgroundJobs/Jobs/ScheduledPublishingJob.cs#L68
Besides ensuring this explicitly completes the scope (using scope.Complete();
), I'm not sure how we can actually fix the issue. We still want to ensure all scheduled content is published on time, so the background job needs to run every minute... But maybe we can avoiding the need to take the write lock every minute?
The same probably also applies to members: every sign-in currently updates the members LastLoginDateUtc
, AccessFailedCount
(if it was more than 0) and security stamp (if AllowConcurrentLogins
is disabled), which takes a write lock on Constants.Locks.MemberTree
...
Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)
10.1
Bug summary
We experiencing deadlocks in the database when lots of members sign in at the same time. During peaks we have around 100 sign ins a minute. We use umbracos default membership provider. The sign ins get very slow and we also see deadlocks in the logs.
Specifics
Setting the logger in debug mode locally I got the following two stacktraces.
Steps to reproduce
I can recreate it locally by using a load testing framework (we used https://locust.io/).
Expected result / actual result
No response