Skip to content

[PR #8247/55e78bb4 backport][3.123] Invalidate the content cache once a new repository version is complete - #8251

Merged
dralley merged 1 commit into
3.123from
patchback/backports/3.123/55e78bb483687549ca3b94cae453018331d49b36/pr-8247
Oct 21, 2026
Merged

dralley merged 1 commit into
3.123from
patchback/backports/3.123/55e78bb483687549ca3b94cae453018331d49b36/pr-8247

Conversation

@patchback

@patchback patchback Bot commented Oct 21, 2026

Copy link
Copy Markdown

This is a backport of PR #8247 as merged into main (55e78bb).

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

  • The call to invalidate_cache() moves from new_version() to RepositoryVersion.__exit__. It runs through transaction.on_commit after the version is complete, so no request can see the previous version after the cache is cleared.
  • A version that changes nothing is discarded and no longer clears the cache.
  • Publications already invalidate after complete=True is 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;
  • the API, cleanup_old_versions and a model hook all refuse to delete them.

Tests

  • pulpcore/tests/unit/models/test_repository_cache.py:

    • the cache is cleared while the new version is already complete;
    • a version without changes leaves the cache alone.

    Both fail without the change.

  • The pulpcore and pulp_file unit suites pass.

Checklist

  • Commits are cleanly separated with meaningful messages (simple features and bug fixes should be squashed to one commit)
  • A changelog entry or entries has been added for any significant changes
  • Follows the Pulp policy on AI Usage
  • (For new features) - User documentation and test coverage has been added

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: #8246
(cherry picked from commit 55e78bb)
@dralley
dralley merged commit 8ef618c into 3.123 Oct 21, 2026
14 checks passed
@dralley
dralley deleted the patchback/backports/3.123/55e78bb483687549ca3b94cae453018331d49b36/pr-8247 branch October 21, 2026 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants