-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Hybrid Cache: Resolve start-up errors with mis-matched types (closes #20537) #20554
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…eval. Ensure nullability of ContentCacheNode is consistent in exists and retrieval.
…uring an initial request is served.
…move, and use of cancellation token.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.
nikolajlauridsen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, and tests good to me too.
I was only able to reproduce by adding an actually redis cache, but then the issue also became very consistent, but this PR fixes it, great work 🎉
* Be consistent in use of GetOrCreateAsync overload in exists and retrieval. Ensure nullability of ContentCacheNode is consistent in exists and retrieval. * Applied suggestion from code review. * Move seeding to Umbraco application starting rather than started, ensuring an initial request is served. * Tighten up hybrid cache exists check with locking around check and remove, and use of cancellation token. (cherry picked from commit 81a8a0c)
|
Cherry picked to release/17.0 👍 |
* Be consistent in use of GetOrCreateAsync overload in exists and retrieval. Ensure nullability of ContentCacheNode is consistent in exists and retrieval. * Applied suggestion from code review. * Move seeding to Umbraco application starting rather than started, ensuring an initial request is served. * Tighten up hybrid cache exists check with locking around check and remove, and use of cancellation token.
|
This pull request has been mentioned on Umbraco community forum. There might be relevant details there: https://forum.umbraco.com/t/umbraco-upgrade-15-4-4-16-3-1-hybridcache-with-the-same-key/6363/4 |
Prerequisites
Addresses: #20537
Description
This PR makes two updates to resolve the linked issue;
For background, this "exists" check was added in #19890 which was introduced to improve start up performance (allowing us to retrieve cached documents in batches from the database rather than one at a time).
I was able to reproduce the problem manually - it seemed to be consistent at least when using the Visual Studio template and IIS Express:
The amends described above resolved the problem with the hybrid cache exception but revealed something else - that we would get an immediate page not found, and then after a refresh, the expected templated page would show. The crux of the problem here seemed to be that we are doing seeding on an application started notification, which doesn't seem correct. We should seed the initial content before we accept requests, and as such I've moved this to an application starting notification. That looks to resolve this problem.
There are some integration tests added in an attempt to replicate the problem. These didn't succeed in doing so, but are probably worth keeping anyway as additional testing around the hybrid cache.
Similarly there's some tightening up around the implementation of the "exists" check (the locking around "check and remove" and the cancellation token handling). None of this turned out to be the smoking gun, but I think they are valid improvements to consider keeping.
Testing
First try to replicate the problem consistently on
mainand then when you can, switch in the code from this PR and verify that the application starts without error and the expected initial page is shown.