Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Content cache is cleared when a repository version is started, so concurrent requests re-cache the previous version

Đã đóng
#8,246 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Một pull request liên quan đã được merge.

  • #8247 của @aevnsvi — đã merge

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
42/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python, redis
Lĩnh vực
backend, databases

Hướng nghiên cứu

Start with Repository.new_version() and RepositoryVersion.__exit__ in pulpcore, then check the cache invalidation tests and how distributions serve repository content. Trace when a version is committed and when the response cache is cleared; done means concurrent requests cannot leave the previous version cached after the version task completes.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Version
pulpcore main (0f6df7d), with the content cache enabled (CACHE_ENABLED = True, Redis).

Describe the bug
Repository.new_version() clears the response cache of the distributions serving the repository when the new version is started. The version only becomes complete later, in RepositoryVersion.__exit__. In between, those distributions are still served from the previous version. A request that arrives in that window puts the previous answer back into the freshly cleared cache. It is then served until the entry expires (CACHE_SETTINGS["EXPIRES_TTL"], 600 seconds by default), although the new version exists by then. Nothing clears the cache again when the version completes.

Without concurrent requests the invalidation works, which makes this easy to miss in a test. Under real traffic, an upload is invisible for up to the full TTL.

To Reproduce
It shows most clearly where an index is served through the cache, for example the pulp_python simple API:

  1. Create a Python repository and a distribution for it, with the cache enabled.
  2. Keep a few clients polling GET /pypi/<base_path>/simple/<name>/, every half second or so.
  3. Upload a new package, or a new version of an existing one, into the repository and wait for the task.
  4. The polling clients keep getting the index without the new file for about ten minutes.

I ran this three times each for a new name and a new version, with four clients polling. The old index stayed cached in every run, and also with a single client. With the cache disabled nothing is stale, so the race is in the invalidation, not in the version itself.

Expected behavior
After the task that creates a repository version has finished, the distributions serving that repository answer from the new version.

Additional context

  • The cache can be cleared once the version is complete and committed instead: in RepositoryVersion.__exit__, through transaction.on_commit. A version that changes nothing is discarded, and would then no longer clear the cache at all.
  • Publications already invalidate after complete=True is saved, so they are not affected.
  • Deleting a version needs no change: a version that a distribution serves is protected from deletion.
  • #2026 is about Redis outages, a different case.

I have a patch with unit tests, and can open it as a PR.

Ngôn ngữ chính
Python
Star
619
Fork
176
Merge trung bình
16 giờ 51 phút
Pull request đã merge (30 ngày)
117

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của pulp/pulpcore

Tất cả issue của pulp/pulpcore

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.