Copied to clipboard

Flag this post as spam?

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


  • Salome 5 posts 95 karma points
    Apr 18, 2023 @ 06:56
    Salome
    0

    Failed to acquire write lock for id: -335.

    Hi,

    We have upgraded Umbraco V7 to V11.

    And whenever we are trying to programmatically save member in database using MemberService or MemberManager, we are getting Failed to acquire write lock for id: -335. Umbraco.Cms.Persistence.SqlServer.Services.SqlServerDistributedLockingMechanism.SqlServerDistributedLock..ctor(SqlServerDistributedLockingMechanism parent, Int32 lockId, DistributedLockType lockType, TimeSpan timeout).

    Have you had any such an experience before? Thank you, indeed!

  • Marc Goodson 2141 posts 14324 karma points MVP 8x c-trib
    Apr 18, 2023 @ 07:45
    Marc Goodson
    0

    Hi Salome

    What is the context of using the memberservice to save? eg a Controller or a background thread?

    Are you saving/updating one member, or is it an import scenario where lots of updates are being made to multiple members?

    And are you wrapping the save inside a Scope? (in V7 you didn't need to)

    https://docs.umbraco.com/umbraco-cms/reference/distributed-locks

    Be good to look in the umbracoLock database table and see what lock is fir -335!

    It sounds like a previous update scope isn't complete, the lock isn't being released before the next attempt to update a Member, my guess would be that by explicitly wrapping the save in it's own scope and calling scope.complete() might resolve the issue, but is a bit of a guess!

    regards

    Marc

  • Hüseyin 12 posts 102 karma points
    Feb 23, 2024 @ 12:40
    Hüseyin
    0

    This happened to me today. I was running health checks and in "data integrity" section it gave me this error:

    Umbraco.Cms.Core.DistributedLocking.Exceptions.DistributedWriteLockTimeoutException: Failed to acquire write lock for id: -333.
       at Umbraco.Cms.Persistence.SqlServer.Services.SqlServerDistributedLockingMechanism.SqlServerDistributedLock..ctor(SqlServerDistributedLockingMechanism parent, Int32 lockId, DistributedLockType lockType, TimeSpan timeout)
       at Umbraco.Cms.Persistence.SqlServer.Services.SqlServerDistributedLockingMechanism.WriteLock(Int32 lockId, Nullable`1 obtainLockTimeout)
       at Umbraco.Cms.Infrastructure.Scoping.Scope.ObtainWriteLock(Int32 lockId, Nullable`1 timeout)
       at Umbraco.Cms.Infrastructure.Scoping.Scope.LockInner(Guid instanceId, Dictionary`2& locks, HashSet`1& locksSet, Action`2 obtainLock, Nullable`1 timeout, Int32 lockId)
       at Umbraco.Cms.Infrastructure.Scoping.Scope.EagerWriteLockInner(Guid instanceId, Nullable`1 timeout, Int32[] lockIds)
       at Umbraco.Cms.Infrastructure.Scoping.Scope.EnsureDbLocks()
       at Umbraco.Cms.Infrastructure.Scoping.Scope.get_Database()
       at Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement.ContentRepositoryBase`3.CheckDataIntegrity(ContentDataIntegrityReportOptions options)
       at Umbraco.Cms.Core.Services.ContentService.CheckDataIntegrity(ContentDataIntegrityReportOptions options)
       at Umbraco.Cms.Core.HealthChecks.Checks.Data.DatabaseIntegrityCheck.<>c__DisplayClass11_0.<CheckDocuments>b__0()
       at Umbraco.Cms.Core.HealthChecks.Checks.Data.DatabaseIntegrityCheck.CheckPaths(String actionAlias, String actionName, String entityType, Boolean detailedReport, Func`1 doCheck)
       at Umbraco.Cms.Core.HealthChecks.Checks.Data.DatabaseIntegrityCheck.CheckDocuments(Boolean fix)
       at Umbraco.Cms.Core.HealthChecks.Checks.Data.DatabaseIntegrityCheck.GetStatus()
       at Umbraco.Cms.Web.BackOffice.HealthChecks.HealthCheckController.GetStatus(Guid id)
    
  • Owain Jones 55 posts 384 karma points MVP 3x c-trib
    Feb 23, 2024 @ 13:03
    Owain Jones
    0

    Hi Hüseyin,

    This issue thread on GitHub, about -333 write lock issues, might be of interest to you: https://github.com/umbraco/Umbraco-CMS/issues/14195

    Specifically, this comment, which explains what a -333 write lock means: https://github.com/umbraco/Umbraco-CMS/issues/14195#issuecomment-1958889246

Please Sign in or register to post replies

Write your reply to:

Draft