fix: make stamps removal sync and data race in psh chunk tests#5446
Open
sbackend123 wants to merge 3 commits intomasterfrom
Open
fix: make stamps removal sync and data race in psh chunk tests#5446sbackend123 wants to merge 3 commits intomasterfrom
sbackend123 wants to merge 3 commits intomasterfrom
Conversation
c21902b to
15e6607
Compare
gacevicljubisa
approved these changes
Apr 30, 2026
acud
reviewed
Apr 30, 2026
| } | ||
|
|
||
| for _, item := range toDelete { | ||
| _ = ps.store.Delete(item) |
Contributor
There was a problem hiding this comment.
here the error is swallowed, while other branches return an error. i would at least check whether an error occurred or not, and return an error (i'm not a big fan of errors.Join as a wall of errors is usually not very helpful - having perhaps just the first error returned is fine while continuing the execute the loop)
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.
Checklist
Description
Collect all matching *StampItem in a slice during the iteration, then Delete only after the iterator returns.
Separate problem: fix data race in TestPushChunkToNextClosest, TestMultiplePushesAsForwarder TestPushChunkToClosestErrorAttemptRetry tests.
The record.bytes() method in streamtest returned a direct reference to the internal slice without holding the mutex, causing a data race when tests read stream records while background goroutines were still writing to them. Fixed by acquiring the lock and returning a copy of the slice.
Open API Spec Version Changes (if applicable)
Motivation and Context (Optional)
Context:
removeStampItemsdeletes allStampItemrows for a given batch by prefix-iterating the stamper store and calling store.Delete for each entry. For a time this used a helper goroutine and an unbuffered channel: the iterator sent each*StampItemto the goroutine, which called Delete outside the callback.That pattern was carried over from an earlier fire-and-forget SetExpired implementation (node startup) where the goal was not to block; it was not a good fit for the later synchronous API,
HandleStampExpiry, where callers and tests expect all matching rows to be gone when the function returns.Bonus problem:
Previous implementation may lead to deadlock.
Many stores protect
IterateandDeletewith a lock, often an RWMutex.With the goroutine + unbuffered channel pattern and more than one StampItem for the same batch prefix we may have scenario:
Related Issue (Optional)
Screenshots (if appropriate):
AI Disclosure