Failed to acquire write lock for id: -333

,

Help :smiley:

Umbraco.Cms.Core.DistributedLocking.Exceptions.DistributedWriteLockTimeoutException: Failed to acquire write lock for id: -333.

Microsoft.Data.SqlClient.SqlException (0x80131904): Lock request time out period exceeded.

I’ve been trying to track this one down for a while. Since we upgraded to Umbraco 10.5.1 for our latest site, this error has been causing us severe issues and we’re about to go live so needs fixed.

As I said, we are running 10.5.1, on Azure but without any sort of load balancing. When the error happens there is sometimes a developer doing things on localhost:port but not today, no one is working on the site and we are still getting the error.

appsettings:

"MainDomLock": "FileSystemMainDomLock",

"LocalTempStorageLocation": "EnvironmentTemp"

"LuceneDirectoryFactory": "SyncedTempFileSystemDirectoryFactory"

Is there anything I should be considering? I have another site that is on 10.3 and never has any issues with -333.

Help :frowning:


This is a companion discussion topic for the original entry at https://our.umbraco.com/forum/111951-failed-to-acquire-write-lock-for-id-333

Many years on and we are still facing this issue on the latest version of 13 :frowning:

Are you connecting to the azure sql db from your local dev machines? It’s not recommended to have multiple instances connect to a single DB.

I am, and we have been for months. But today the issue appeared. And I was the only one developing on the site at the time it appeared. It wasn’t a live site.

It really, imho, shouldn’t be a thing unless two people are saving the same node at the same time. I understand concurrency issues with content.

But people working on completely separate nodes should never be locked out of saving anything anywhere in the back office. And then -333 should clear itself in 5-10 seconds. But it locks and never releases itself and we have to do nuclear option of turning the app service off and on again.

Azure SQL server should be able to handle 10s of connections at the same time without issues :pensive_face:

Again, all imho. Love Umbraco to bits, but this one persistent issue shouldn’t be an issue no matter where I connect to the database from.

It’s more how the cache is built up on app startup / restart I believe rather than locks on access to a single node.

Running DBs locally and syncing doctype changes via usync avoids these issues and is better for deployments in my experience. I know the caching strategies have changes since > v13 so this limitation might just be due to the legacy nucache. Not sure.

You’re right about it not being a lock on a single node, when -333 starts it causes errors across the board. But we don’t always see it on startup/restarts, and if that was the case everyone coming out and the server being restarted surely should clear locks?

Lock -333 is a lock on the content tree. This is when something is saved and published for instance. So if you have like a service that loops through a number of work items and saves and publishes in that loop, you can run into this issue. Because each save and publish puts a lock on -333, performs it’s things and releases the lock, if you spam it, it cannot process fast enough and eventually, you cannot get a lock on time.

So this COULD technically happen if Umbraco doesn’t do something correctly, but most of the time, it’s custom code or packages that cause this issue. And yes, if you have a lock on -333, it has impact on a lot of things obviously.

Solutions are:

  • Create a scope when saving and publishing multiple items so that they are combined into a single transation to the database
  • Use a background job for the work that needs to be done.

This is always an annoying one. The root cause is well understood as something going running and locking the content nodes. I usually debug it by turning off custom code (especially scheduled jobs) one at a time and seeing if things improve.

Locally, the site usually runs slow until it locks, so you’ll know if you’ve solved it because things will instantly go faster.

Good luck!

Unfortunately we rarely run custom code of any kind. Our websites are very vanilla for the most part, all brochureware.

Why are locks not releasing after a certain time and any transactions rolled back?