fix(preview): keep the local file when losing the insert race - #63376
Merged
Conversation
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
solracsf
requested review from
SystemKeeper,
come-nc,
icewind1991,
leftybournes and
provokateurin
and removed request for
a team
August 18, 2026 10:57
CarlSchwan
approved these changes
Aug 18, 2026
SystemKeeper
approved these changes
Aug 18, 2026
Contributor
|
Thank you! |
Contributor
|
/backport to stable34 |
Member
|
/backport to stable33 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: #63348
savePreview()writes the preview file before inserting its row. When two requests generate the same preview at once, the loser hits the unique constraint and then deleted the file it had written.On an object store that is correct: the
urnembeds the preview id, so the object belongs to the losing entity alone. Locally it is not, becauseconstructPath()keys on the file id and the preview specification and never on the preview id, so both requests write the very same path. The loser therefore deleted the file the winner had just committed a row for, leaving a preview that can never be read again.Split the two cases behind
deleteUnreferencedPreview(), which removes the stored data only when the backend keys it by preview id.Note
I chose this over the lazy alternative, catching
NotFoundExceptionat the read and regenerating there, because that path has to re-derive$maxWidth/$maxHeightmid-loop after they've already been captured and used bycalculateSize(), which is exactly the kind of retry logic that breeds bugs.