Repository navigation
Invalidate the content cache once a new repository version is complete - #8247
Conversation
| Fixed responses for a distribution being cached from the previous repository version, and served | ||
| until the cache entry expired, when they were requested while a new version was being created. |
There was a problem hiding this comment.
Can you put this on one line.
| # Only now: until the new version is complete and committed, a request | ||
| # is answered from the previous version, and clearing the cache earlier | ||
| # would let that answer be cached again and served until it expires. |
3c4dd54 to
af41170
Compare
| @@ -0,0 +1,65 @@ | |||
| import hashlib | |||
There was a problem hiding this comment.
We have a handful of similar tests in pulpcore/tests/unit/models/test_publication_retention.py
Could you move these tests there, and group them together in a class as those tests are? The file name should probably be changed but for now I'd rather prioritize keeping the tests together.
Maybe rename the file to test_caching_and_retention.py
There was a problem hiding this comment.
Moved them into a TestCacheInvalidationOnRepositoryVersionCreate class in test_caching_and_retention.py (renamed from test_publication_retention.py).
|
The patch looks good to me, just small requested test changes. |
|
@aevnsvi ^ |
Repository.new_version() cleared the cache of the distributions serving the repository when the new version was started. Until that version is complete, those distributions are still served from the previous one, so a response computed in that window was put back into the cache and served until it expired (ten minutes by default), although the new version had been created in the meantime. Clear the cache once the new version is complete and committed instead. A version that changes nothing is discarded and no longer clears the cache. Closes: pulp#8246
af41170 to
4279fa4
Compare
Backport to 3.85: 💔 cherry-picking failed — conflicts found❌ Failed to cleanly apply 55e78bb on top of patchback/backports/3.85/55e78bb483687549ca3b94cae453018331d49b36/pr-8247 Backporting merged PR #8247 into main
🤖 @patchback |
Backport to 3.123: 💚 backport PR created✅ Backport PR branch: Backported as #8251 🤖 @patchback |
Backport to 3.118: 💚 backport PR created✅ Backport PR branch: Backported as #8252 🤖 @patchback |
|
Beep beep boop! Somebody's just asked me to create a backport of this pull request Please, expect to see further updates regarding my progress in updates If you think I'm experiencing problems, ping 🤖 @patchback |
Backport to 3.105: 💔 cherry-picking failed — conflicts found❌ Failed to cleanly apply 55e78bb on top of patchback/backports/3.105/55e78bb483687549ca3b94cae453018331d49b36/pr-8247 Backporting merged PR #8247 into main
🤖 @patchback |
Closes #8246
Repository.new_version()cleared the content cache of the distributions serving the repository when the new version was started. Until the version is complete, those distributions still serve the previous one. A request in that window therefore put the previous answer back into the cache, and it was served until it expired (ten minutes by default). Details and a reproducer are in #8246.What changes
invalidate_cache()moves fromnew_version()toRepositoryVersion.__exit__. It runs throughtransaction.on_commitafter the version is complete, so no request can see the previous version after the cache is cleared.complete=Trueis saved. They are not touched.Why version deletion needs no change
RepositoryVersion.delete()also clears the cache before its own transaction commits. But a version that any distribution serves cannot be deleted:protected_versions()covers versions set on a distribution, versions behind distributed publications and checkpoints, and the version a repository distribution serves;cleanup_old_versionsand a model hook all refuse to delete them.Tests
pulpcore/tests/unit/models/test_repository_cache.py:Both fail without the change.
The pulpcore and pulp_file unit suites pass.
Checklist