Resolved exception thrown from NuCache locking mechanism on near-simultaneous content publish requests #19434
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Prerequisites
Resolves: #19338
Description
The linked issue reports a regression after #17246, which was introduced to avoid locking exceptions in asynchronous code.
It seems that after this, near-simultaneous requests to save and publish content results in one or more of the requests failing due to NuCache being unable to acquire a lock (the
SemaphoneSlimthat's it's based on not being released from the previous operation). You would then find the content created and published, but the failed ones wouldn't be in the cache, which is manifested in the backoffice by the message of "published but not in the cache" shown where the URLs are displayed on the "Info" panel.To resolve I've removed the "fast-fail" check we had before waiting for the
SemaphoneSlim, and allowed the wait to pick up the lock when released from the previous operation.Some advice from @ronaldbarendse:
Testing
The original issue can be replicated as shown in the linked issue from the browser console when logged into the backoffice.
You should find with this PR in place multiple requests to create, save and publish content will succeed.