fix: shut down the P2P subsystem on DB.Close - #5133
Draft
mennatnaga wants to merge 1 commit into
Draft
Conversation
mennatnaga
force-pushed
the
menna/car-import-existence-guard
branch
from
August 12, 2026 14:03
8796070 to
5573071
Compare
mennatnaga
force-pushed
the
menna/p2p-close-race
branch
from
August 12, 2026 14:03
b7b1c46 to
d359c26
Compare
mennatnaga
force-pushed
the
menna/car-import-existence-guard
branch
from
August 12, 2026 15:14
5573071 to
3567a2f
Compare
mennatnaga
force-pushed
the
menna/p2p-close-race
branch
from
August 12, 2026 15:14
d359c26 to
0550de8
Compare
mennatnaga
force-pushed
the
menna/car-import-existence-guard
branch
from
August 13, 2026 11:26
3567a2f to
80e8510
Compare
Base automatically changed from
menna/car-import-existence-guard
to
menna/blockstore-orphan-gc
August 13, 2026 11:26
mennatnaga
changed the base branch from
menna/blockstore-orphan-gc
to
menna/fetcher-prefix-iterator
August 13, 2026 12:04
mennatnaga
force-pushed
the
menna/p2p-close-race
branch
from
August 13, 2026 12:04
0550de8 to
f191251
Compare
mennatnaga
force-pushed
the
menna/fetcher-prefix-iterator
branch
from
August 13, 2026 16:14
7313e0b to
4d087a1
Compare
mennatnaga
force-pushed
the
menna/p2p-close-race
branch
from
August 13, 2026 16:21
f191251 to
29198d5
Compare
jsimnz
reviewed
Aug 13, 2026
Comment on lines
+687
to
690
| case <-p.stopAccepting: | ||
| p.releaseQueueBytes(size) | ||
| case <-p.ctx.Done(): | ||
| p.releaseQueueBytes(size) |
Member
There was a problem hiding this comment.
question: Without this PR, shouldn't the ctx.Done case be able to handle this graceful shutdown if you cancel the context object referenced?
Member
Author
There was a problem hiding this comment.
you're right, DB.Close cancels p.ctx, so ctx.Done already covers this - I will fix this once I finalise the other prs
mennatnaga
force-pushed
the
menna/fetcher-prefix-iterator
branch
from
August 13, 2026 23:15
4d087a1 to
4f5c155
Compare
mennatnaga
force-pushed
the
menna/p2p-close-race
branch
from
August 13, 2026 23:15
29198d5 to
812fe3e
Compare
mennatnaga
force-pushed
the
menna/fetcher-prefix-iterator
branch
from
August 14, 2026 00:45
4f5c155 to
161af74
Compare
mennatnaga
force-pushed
the
menna/p2p-close-race
branch
from
August 14, 2026 00:45
812fe3e to
26724c7
Compare
mennatnaga
force-pushed
the
menna/fetcher-prefix-iterator
branch
from
August 14, 2026 18:28
161af74 to
fe2b7e7
Compare
mennatnaga
force-pushed
the
menna/p2p-close-race
branch
from
August 14, 2026 18:28
26724c7 to
8921989
Compare
mennatnaga
force-pushed
the
menna/fetcher-prefix-iterator
branch
from
August 14, 2026 18:56
fe2b7e7 to
1f4e3d1
Compare
mennatnaga
force-pushed
the
menna/p2p-close-race
branch
from
August 14, 2026 18:56
8921989 to
879ea9b
Compare
mennatnaga
force-pushed
the
menna/fetcher-prefix-iterator
branch
from
August 27, 2026 13:23
1f4e3d1 to
1501d69
Compare
mennatnaga
force-pushed
the
menna/p2p-close-race
branch
from
August 27, 2026 13:23
879ea9b to
278962c
Compare
An error occurred while trying to automatically change base from
menna/fetcher-prefix-iterator
to
menna/purge-chunk-size
August 28, 2026 18:27
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.
Stacked on #5137.
Closeclosed the message queue to stop the workers. The pubsub dispatcher keeps calling the handler until libp2p tears the subscription down, whichClosedoes not do, and a send on a closed channel is a ready case in a select rather than a fallthrough to the default arm, so a message arriving during shutdown panics the dispatcher. The queue is now left open and a separate signal ends the worker pool.Not complete.
(*P2P).Closehas no production caller, so the panic is unreachable as things stand:node.Peerisgithub.com/sourcenetwork/go-p2p, son.peer.Close()does not reach this one. WiringDB.Closeto shut the P2P subsystem down is what makes this matter, and that is not done here.