Recursive locks in editor & background tasks since upgrade to umbraco 13

,

Hi,

We have multiple scheduled tasks running that modify and save content.

Here are two improvements I made:

  • Scoped SaveAndPublish Operations:
    I added scopes specifically around the .SaveAndPublish calls. These scopes are kept as small as possible and do not wrap large blocks of code.
  • Semaphore for Task Synchronization:
    I implemented a semaphore to ensure that only one task runs at a time:

Additionally, I fixed a bug that seemed to trigger the exception (I was able to reproduce it).
We have a strategy in Umbraco that executes during content publishing. This strategy was running code that sent an email asynchronously. I changed the email sending process to synchronous execution, which resolved the issue.

I’m not entirely sure if these changes fully resolve the recursive lock error, but I haven’t encountered it since.
It’s still possible that this issue might occur while editors are actively working on content. That’s why I believe it’s crucial to keep the scope limited strictly to the .SaveAndPublish operations to minimize the chance of overlapping actions.