test(kademlia): deflake TestAddressBookQuickPrune and TestOutofDepthPrune#5508
Open
martinconic wants to merge 2 commits into
Open
test(kademlia): deflake TestAddressBookQuickPrune and TestOutofDepthPrune#5508martinconic wants to merge 2 commits into
martinconic wants to merge 2 commits into
Conversation
sbackend123
reviewed
Jun 22, 2026
…rune with synctest
acud
requested changes
Jun 22, 2026
| logger log.Logger // logger | ||
| bootnode bool // indicates whether the node is working in bootnode mode | ||
| collector *im.Collector | ||
| metricsDB *shed.DB // backing store for the metrics collector; closed on shutdown |
Contributor
There was a problem hiding this comment.
i don't understand why this is needed. it does not appear anywhere else in the diff. if this is added because a test needs it then it probably lives in the wrong place. if this is some leftover from another place then probably should be removed.
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
Deflakes two timing-sensitive tests in
pkg/topology/kademliathat intermittently fail in CI on unrelated branches:TestAddressBookQuickPrune— e.g.kademlia_test.go: timed out waiting for counter ... got 3 want >= 4TestOutofDepthPrune— e.g.kademlia_test.go: bin 5, got 14, want more than 16Both failures are test-harness timing bugs: the tests gated async connect/prune progress on fixed
time.Sleepbarriers and on the assumption that eachTrigger()yields exactly one dial, which breaks under load (a trigger landing inside a peer'sTimeToRetrywindow is skipped; a 500ms barrier is not always enough on a loaded runner).Product change required by this approach. synctest demands that every goroutine started inside the bubble terminates before the test ends. Kademlia's metrics collector opens an in-memory leveldb in
New(shed.NewDB), but the*shed.DBhandle was passed to the collector and then dropped —Closenever closed it. This is a real (if low-severity) resource/goroutine leak that was masked in tests by thegoleakignores inmain_test.go. We now retain the store handle on theKadstruct and close it inClose, after the collector is finalized. With the store closed, the leveldb compaction/session goroutines exit.AI Disclosure