Does anyone know why we keep getting this write lock error in the backoffice?
Whenever the error starts appearing, it throws the error when saving anything. The error will disappear after a while (x number of minutes).
Can the timeout be changed? Or can I do anything else to make sure this won't happen?
An error occurred
Failed to acquire write lock for id: -333.
Exception Details
Umbraco.Cms.Core.DistributedLocking.Exceptions.DistributedWriteLockTimeoutException, Umbraco.Core, Version=10.3.2.0, Culture=neutral, PublicKeyToken=null: Failed to acquire write lock for id: -333.
Stacktrace
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.ContentTypeRepositoryBase`1.PersistUpdatedBaseContentType(IContentTypeComposition entity)
at Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement.ContentTypeRepository.PersistUpdatedItem(IContentType entity)
at Umbraco.Cms.Core.Cache.FullDataSetRepositoryCachePolicy`2.Update(TEntity entity, Action`1 persistUpdated)
at Umbraco.Cms.Core.Services.ContentTypeServiceBase`2.Save(TItem item, Int32 userId)
at Umbraco.Cms.Web.BackOffice.Controllers.ContentTypeController.<PostSave>b__30_1(IContentType type)
at Umbraco.Cms.Web.BackOffice.Controllers.ContentTypeControllerBase`1.PerformPostSave[TContentTypeDisplay,TContentTypeSave,TPropertyType](TContentTypeSave contentTypeSave, Func`2 getContentType, Action`1 saveContentType, Action`1 beforeCreateNew)
at Umbraco.Cms.Web.BackOffice.Controllers.ContentTypeController.PostSave(DocumentTypeSave contentTypeSave)
at lambda_method84(Closure , Object , Object[] )
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
Hey Rune,
I cannot offer a solution for this, but I am running into this a lot as well. I am running into a lot of performance issues with v10. Database and NuCache locking issues often and extremely slow performance.
Have you found anything new to the cause or solution?
In this latest case the website runs on an MS SQL 15.0.4261 on a linux server. The Umbraco website is also running on Linux, but we are experiencing the problem from our local windows dev machines that uses the same linux served database.
It might have something to do with us running multiple websites against the same database? But why would that be an issue on Umbraco 10. That was never an issue on Umbraco 7 and 8!
Working from a shared database will most likely be the cause of this issue, because in Umbraco terms you are now loadbalancing (multiple servers connecting to the same database).
You will probably would have issues on V7 and V8 as well, but you might not have noticed them. Probably you faced issues like content cache or examine indexes not being up to date after publishing.
Maybe the following things can help you fix the problem.
But this is not guaranteed to fix the issue. We always use local databases for development and sync schema changes using uSync or Umbraco Deploy (when working with Cloud).
Just a little heads up. No luck with Daves proposal.
I have been debugging with a debug build of Umbraco and found out that when getting the error on a content save and publish the error appears when the DocumentRepository tries to Fetch a ContentScheduleDto in the GetContentSchedule() method.
Stepping through the code other lock call before this actually succeeds in getting a database lock, but this one doesn't. Not sure if that makes any sence and I'm not in to the science behind it.
No conclusion yet. What we are trying right now is using uSync instead of all connecting to the same database. That might have had a positive effect. Last week we did not experience the error though.
Just a small follow-up on this one. We recently updated to Umbraco 10.4 and this have not fixed the problem. We are still experiencing the issue from time to time on different machines.
I have also been having this issue. I have several Umbraco sites but it only seems to happen in one of them. It is has over 1000 pages but it is not the largest site - sites with more pages on the same server do not evidence the same problem.
Rebuild database cache can help but seems to be a temporary fix.
Just a small update on this issue, or whatever you can call it.
After we have started strictly having one instance per database we have not had the issue quite as much.
When deploying the website we sometime have to restart the sql-server though. So the problem is not entirely gone.
I've just seen this for the first time myself today. I've been working on Umbraco sites since 2011.
What I've noticed today is that running on an Ubuntu server is where I see the issue. I can have the site running on localhost pointed at the same database. Trying to delete an item from the Media section on the instance running on a browser gives the "Failed to acquire write lock for id: -334." error. Moving over to my local version and doing the same operation - just fine.
I am experiencing this issue on one of our databases. And only one website is connected to it so I doubt it's anything to do with supposed load balancing.
We are only experiecing it in one environment while the other ones (that connect to their own databases) are working well.
SQL write lock failure
Hi people,
Umbraco v10.
Does anyone know why we keep getting this write lock error in the backoffice? Whenever the error starts appearing, it throws the error when saving anything. The error will disappear after a while (x number of minutes).
Can the timeout be changed? Or can I do anything else to make sure this won't happen?
Hey Rune, I cannot offer a solution for this, but I am running into this a lot as well. I am running into a lot of performance issues with v10. Database and NuCache locking issues often and extremely slow performance.
Have you found anything new to the cause or solution?
Hi Rune,
Can I ask what kind of server setup you have. I'm not experiencing this.
Dave
Hi Dave,
In this latest case the website runs on an MS SQL 15.0.4261 on a linux server. The Umbraco website is also running on Linux, but we are experiencing the problem from our local windows dev machines that uses the same linux served database.
It might have something to do with us running multiple websites against the same database? But why would that be an issue on Umbraco 10. That was never an issue on Umbraco 7 and 8!
/Rune
Hi Rune,
Working from a shared database will most likely be the cause of this issue, because in Umbraco terms you are now loadbalancing (multiple servers connecting to the same database).
You will probably would have issues on V7 and V8 as well, but you might not have noticed them. Probably you faced issues like content cache or examine indexes not being up to date after publishing.
Maybe the following things can help you fix the problem.
But this is not guaranteed to fix the issue. We always use local databases for development and sync schema changes using uSync or Umbraco Deploy (when working with Cloud).
Dave
Brilliant. I will try that. It's only while in the development phase we do this, but it would be nice not to have to worry about it.
/Rune
Just a little heads up. No luck with Daves proposal.
I have been debugging with a debug build of Umbraco and found out that when getting the error on a content save and publish the error appears when the DocumentRepository tries to Fetch a ContentScheduleDto in the GetContentSchedule() method.
Stepping through the code other lock call before this actually succeeds in getting a database lock, but this one doesn't. Not sure if that makes any sence and I'm not in to the science behind it.
/Rune
Hi Rune,
Have you tried updating to Umbraco 10.4.0 ? It may be worth doing so to see if any resolved issues are at fault.
Any more news on this Rune? I'm getting this exact error on save and publish as well. Did upgrading Umbraco help?
Hi John,
No conclusion yet. What we are trying right now is using uSync instead of all connecting to the same database. That might have had a positive effect. Last week we did not experience the error though.
/Rune
Just a small follow-up on this one. We recently updated to Umbraco 10.4 and this have not fixed the problem. We are still experiencing the issue from time to time on different machines.
I have also been having this issue. I have several Umbraco sites but it only seems to happen in one of them. It is has over 1000 pages but it is not the largest site - sites with more pages on the same server do not evidence the same problem.
Rebuild database cache can help but seems to be a temporary fix.
Just a small update on this issue, or whatever you can call it. After we have started strictly having one instance per database we have not had the issue quite as much. When deploying the website we sometime have to restart the sql-server though. So the problem is not entirely gone.
/Rune
I've just seen this for the first time myself today. I've been working on Umbraco sites since 2011.
What I've noticed today is that running on an Ubuntu server is where I see the issue. I can have the site running on localhost pointed at the same database. Trying to delete an item from the Media section on the instance running on a browser gives the "Failed to acquire write lock for id: -334." error. Moving over to my local version and doing the same operation - just fine.
I am experiencing this issue on one of our databases. And only one website is connected to it so I doubt it's anything to do with supposed load balancing.
We are only experiecing it in one environment while the other ones (that connect to their own databases) are working well.
Yes, same here. It can happen in multiple cases including where there's just one instance working on the database.
Related: https://github.com/umbraco/Umbraco-CMS/issues/14195
https://discord-chats.umbraco.com/t/18819663/failed-to-acquire-write-lock-for-id-33
is working on a reply...