mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 10:38:37 +00:00
WIP: ipc: make ipc::disconnectIncoming wait for in-progress calls to complete #35932
No reviewers
Labels
No labels
Android
Backport
Block storage
Brainstorming
Bug
Build system
CI failed
Consensus
Data corruption
Descriptors
Docs
DrahtBot Guix build requested
Feature
Fuzzing
GUI
Good First Review
IPC
Insufficient Review
Kernel
Linux/Unix
Mempool
Mining
Needs Backport (31.x)
Needs Backport (32.x)
Needs Benchmark
Needs Conceptual Review
Needs backport (30.x)
Needs rebase
Needs release note
Net
P2P
PSBT
Privacy
Private Broadcast
Questions and Help
RPC/REST/ZMQ
Refactoring
Resource usage
Review club
Scripts and tools
Settings
TX fees and policy
Tests
Tracking Issue
UTXO Db and Indexes
Up for grabs
Upstream
Utils/log/libs
Validation
Waiting for author
Wallet
Windows
good first issue
interfaces
macOS
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin/bitcoin!35932
Loading…
Reference in a new issue
No description provided.
Delete branch "pr/diswait"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This fixes an antithesis bug reported in https://github.com/bitcoin/bitcoin/issues/35845 and similar bug reported in https://github.com/bitcoin/bitcoin/issues/33387 where if asynchronous IPC mining calls are made when the node is shutting down it's possible for
assert(m_node.chainman)to trigger. This happens because theIpc::disconnectIncomingmethod does not wait for asynchronous calls to complete after it disconnects IPC clients, so they may continue to run as the node is shutting down.This PR changes
disconnectIncomingto wait for asynchronous calls to complete to avoid this issue. It's a draft because it depends on libmultiprocess changes, but should otherwise be ready to review.This is based on bitcoin-core/libmultiprocess#361 and bitcoin-core/libmultiprocess#335, and also includes a
src/ipc/libmultiprocesssubtree update. The non-base commits to review are:3e1518c9deaipc: use ServeStream/ConnectStream in Bitcoin Core IPC code5c34fe4c4d0ipc: drain in-flight server calls before shutdown frees node stateStatus (2026-11-23)
This is a draft because it waits on bitcoin-core/libmultiprocess#361 and bitcoin-core/libmultiprocess#335 and a subtree update that includes them. This push fixes a shutdown hang the previous version had: if an IPC client was still connected at shutdown, the disconnected connections stayed in the incoming connection list and kept the IPC event loop running, so the node never exited. bitcoin-core/libmultiprocess#335 now frees connections after
disconnect(), this PR waits on the trackersdisconnect()returns, and a new functional test stops the node with a client connected.The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
External sites
Reviews
See the guideline and AI policy for information on the review process.
A summary of reviews will appear here.
Conflicts
Reviewers, this pull request conflicts with the following ones:
CapnpProtocolby nullfail)If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
🚧 At least one of the CI tasks failed.
Task
lint: https://github.com/bitcoin/bitcoin/actions/runs/31186529513/job/92892361418LLM reason (✨ experimental): CI failed due to the lint “subtree” check detecting a subtree directory change without a corresponding subtree merge.
Hints
Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:
Possibly due to a silent merge conflict (the changes in this pull request being
incompatible with the current code in the target branch). If so, make sure to rebase on the latest
commit of the target branch.
A sanitizer issue, which can only be found by compiling with the sanitizer and running the
affected test.
An intermittent issue.
Leave a comment here, if you need help tracking down a confusing failure.
Updated b0c970e305fde426f4aacc8f8d9ea55ea6e8e210 ->
451f5455d6(pr/diswait.4->pr/diswait.5, compare) usingincoming_connections()accessor for compatibility with https://github.com/bitcoin-core/libmultiprocess/pull/336Rebased
451f5455d6->9586480415(pr/diswait.5->pr/diswait.6, compare) onto a libmultiprocess subtree bump (master plus sockinline fixes) fixing subtree (lint job)Added 1 commits
9586480415->222bf56d31(pr/diswait.6->pr/diswait.7, compare) restoring the commit that skips the subtree lint check, which this PR still needs because it includes libmultiprocess changes (lint job)Squashed
222bf56d31->228ca73a64(pr/diswait.7->pr/diswait.8, compare) moving the "ipc: use ServeStream/ConnectStream/incomingConnections in Bitcoin Core IPC code" commit after the commits adding those helpers, so every commit builds (test ancestor commits job); no changes to the final codeRebased
228ca73a64->01a01e35d9(pr/diswait.8->pr/diswait.9, compare) due to conflicts with #36747 and #36682. Drops the four ConnectStream/ServeStream commits and the-Wc++23-lambda-attributesbuild fix, which reached master in #36747 (the ConnectStream/ServeStream commits as bitcoin-core/libmultiprocess#365).Updated
01a01e35d9->74730ac411(pr/diswait.9->pr/diswait.10, compare) updating the bitcoin-core/libmultiprocess#361 and bitcoin-core/libmultiprocess#335 commits to pr/ondis.6 and pr/keepconn.9, and fixing a shutdown hang when an IPC client is still connected (reported by enochaz in https://github.com/bitcoin-core/libmultiprocess/pull/336#pullrequestreview-6022372666) by waiting on the trackers disconnect() now returns, with a new functional testThis should be fixed by https://github.com/bitcoin-core/libmultiprocess/pull/335 + #35932
Earlier concerns remain unresolved; see the Run archive linked from the Review report.
🔴 Major · Canceling
destroy()can deadlock the IPC event loopCanceling an
mp.Contextdestroy()between callback installation and its implementation-handoffsync()can deadlock the worker and event loop, hanging IPC and shutdown; no occurrence has been observed.Location:
src/ipc/libmultiprocess/include/mp/proxy-io.h:904(head).🟠 Minor · Shutdown can restart a full IPC listener and admit an undrained client
With a full
-ipcbindlistener and a queued client, local shutdown disconnection can restart acceptance after the drain snapshot and delay exit until that client disconnects; no current workload producing this shutdown condition was identified.Location:
src/ipc/libmultiprocess/include/mp/proxy-io.h:1126(head).🔵 Suggestion · The new tests do not exercise the protocol-level drain wait
The functional test stops with an idle client, while the library test waits on the tracker directly; neither checks that
CapnpProtocol::disconnectIncoming()waits for a running call body.Location:
test/functional/interface_ipc.py:194(head).🔵 Suggestion ·
onDisconnect()documents the wrong local-disconnect behaviorThe comments say
disconnect()expiresm_aliveand suppresses handlers, but it deliberately preserves the token so handlers free the connection; only destruction expires it.Location:
src/ipc/libmultiprocess/include/mp/proxy-io.h:637(head).🔵 Suggestion · The
onDisconnect()regression test misses the expired-token guardThe test runs the handler before deferred connection destruction, so removing the
alive.expired()guard would leave its assertions unchanged.Location:
src/ipc/libmultiprocess/test/mp/test/test.cpp:919(head).🔵 Suggestion · The commit messages describe a stale drain and ownership sequence
5c34fe4describes a nonexistentConnection::waitDrained()and an explicit destruction step, obscuring the ownership dependency;3e1518calso describes already-existing helpers as newly added.Location: src/ipc/capnp/protocol.cpp:158 (commit).
Review coverage was incomplete.
Reviewed:
c7bb29320041· Review report · Previous reportspermalink
🐙 This pull request conflicts with the target branch and needs rebase.