Skip to content

p2p/discover: track active topic searches so they stop on shutdown#91

Closed
srene wants to merge 1 commit into
topdiscfrom
fix/topicsystem-search-tracking
Closed

p2p/discover: track active topic searches so they stop on shutdown#91
srene wants to merge 1 commit into
topdiscfrom
fix/topicsystem-search-tracking

Conversation

@srene

@srene srene commented Jul 19, 2026

Copy link
Copy Markdown
Member

Closes #28

topicSystem tracked registrations but not searches, so searches created
via newSearchIterator kept their goroutines running past UDPv5.Close.
Track live searches in the system and stop them in stop(); make
topicSearch.stop idempotent so the iterator Close and shutdown paths can
both call it safely.
@srene

srene commented Jul 20, 2026

Copy link
Copy Markdown
Member Author

Closing for now — deprioritized, not rejected.

The only consumer of TopicSearch is the devp2p discAPI RPC (cmd/devp2p/discv5cmd.go), which already closes the iterator (defer it.Close() plus a searchTimeout goroutine); topic search is not wired into p2p.Server's dialer. So searches don't leak in normal operation. The real exposure is only the window where UDPv5.Close races an in-flight search RPC, and even then the leak is bounded by the consumer's searchTimeout, not permanent.

The fix itself is correct — track searches in topicSystem, stop them from sys.stop(), with stopOnce + removeSearch for idempotent shutdown. Given the bounded exposure it's just not worth carrying right now. Keeping #28 open to track making Close self-contained (and as a prerequisite for the iterator/Close refactor).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

topicSystem: active topicSearches aren't tracked — UDPv5.Close doesn't stop them

1 participant