coordinator: fix race condition in authority test#1371
Merged
Conversation
katexochen
reviewed
Apr 14, 2025
| } | ||
| } | ||
| m.logger.Error("WatchLatestTransitions failed, starting a new watcher", "error", err) | ||
| t := m.clock.NewTimer(5 * time.Second) |
Contributor
There was a problem hiding this comment.
I think clock.After should be fine, it makes the code much more readable and shouldn't leak anything at this point.
Member
Author
There was a problem hiding this comment.
Cool, reverted back to clock.After.
bfc3be9 to
209fc37
Compare
katexochen
approved these changes
Apr 15, 2025
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.
It turns out that #1317 introduced two race conditions in test code:
clock.After, the notification about the step would go nowhere and the watcher would wait forever to restart the loop.badStore.Watchwe sent a notification about the call happening before actually handing out the channel. This could lead to the caller receiving the new channel, not the one the test logic was closing.I fixed both, restructured the test code so that the main test logic is easier to understand (by hiding the channel sends and receives in functions of store and clock), and switched from
clock.Aftertoclock.NewTimerbecauseclock.Afteris still documented to leak resources (not sure whether this is still the case, though, as this was fixed at least in thetimepackage).Tested: