Repository navigation
Conversation
3a3f598 to
084bed1
Compare
gerrod3
left a comment
There was a problem hiding this comment.
Thanks for the fix! For the second issue can we try to just reverse the order of the lookup to try pending blobs first? I'm currently not liking the read only transaction.
Mmm... yeah, the more I think about it the less happy I am with it. It continues to feel a bit too hacky. I will try to re-work it this weekend when I have time. I appreciate the feedback. |
The content app could answer 404 for a pull-through blob in two windows while the task adding it to the repository committed: - finalize_new_version cleared the blob from pending_blobs, and that committed before pulpcore committed the version as complete. - get_by_digest read the repository version and looked the blob up in separate statements, so a commit in between hid the blob. Clear pending content in on_new_version, after the version is complete, and look the blob up in pending_blobs before reading the repository version. fixes pulp#2626 Assisted-by: Claude Opus 5.5
084bed1 to
6127c98
Compare
Reworked as suggested. Dropping the transaction costs at most one query and makes the code easier to read. get_by_digest now:
The version is read only after the pending lookup, so it can't miss a version that commits in between; test_blob_served_when_version_commits_between_lookups covers that. I also switched aget to afirst, since a blob has only one ContentArtifact for its digest. |
gerrod3
left a comment
There was a problem hiding this comment.
Realized this change exposed another bug I hadn't notice before. When using repository_version on a container distribution it shouldn't read from the repository's pending_blob/manifest content. Also, I believe it doesn't make sense to set repository_version and remote on the same distribution.
Let me know if you can work on this bug as well, otherwise we can scope this PR to just the race-condition bugfix.
| # A blob being added to the repository is always either pending or in the latest | ||
| # version, so look in the pending blobs first and in the latest version second. |
There was a problem hiding this comment.
The code is easy to understand, the comment should reflect why the order has to be the way it is. Something like To avoid race condition content must always be read pending first, then latest_version, see ContainerRepository.on_new_version
| ) | ||
| ca = await blob_artifacts.filter(content__in=repository.pending_blobs.all()).afirst() | ||
|
|
||
| # Not pending: look in the latest version, read only now so that it is no older |
There was a problem hiding this comment.
Then you can remove the rest of these comments.
| repository = await sync_to_async(self._get_repository)(distribution) | ||
| if repository is None: |
There was a problem hiding this comment.
This logic isn't what we want.
ContainerDistributions can have Repository or RepositoryVersion set. Only when setting Repository (i.e always use latest content) do we want to read the pending content. Else we should just read from the repo version's content. I know this isn't how it worked before, but I am now realizing that was a bug.
There was a problem hiding this comment.
Heh.. so fixated on 'getting the version I just fetched returned' that should have been obvious.
Although the initial race was seen when I was doing a pull through fetch for something that was not in the cache at all, which means it would still fail (although the occurrence is probably rare), and a subsequent try would succeed.
I am about to go on vacation for two weeks (back in the second week of December) if it is okay to wait until then, I can work on that bug. |
The content app could answer 404 for a pull-through blob in two windows while the task adding it to the repository committed:
Clear pending content in on_new_version, after the version is complete, and look the blob up in pending_blobs before reading the repository version.
fixes #2626
Assisted-by: Claude Opus 5.5
📜 Checklist
See: Pull Request Walkthrough