Skip to content

net: make disconnectnode clear peers promptly (mempool_reorg flake) - #304

Merged
reardencode merged 4 commits into
masterfrom
net/disconnect-peer-prompt
Aug 29, 2026
Merged

net: make disconnectnode clear peers promptly (mempool_reorg flake)#304
reardencode merged 4 commits into
masterfrom
net/disconnect-peer-prompt

Conversation

@rearden-grok

@rearden-grok rearden-grok Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Nightly core-functional attempt 1 of run 33253285378 failed on mempool_reorg.py: disconnect_nodes timed out (5s) waiting for the far side to drop the peer from getpeerinfo.

disconnectnode only set a stop flag; TCP FIN / far-side EOF could wait on our session loop, and local getpeerinfo kept the row until teardown.

Fix:

  • On disconnect_id, Shutdown::Both on a cloned std TCP fd (from open_v2), abort writer + session tasks, unregister immediately.
  • Wire session AbortHandle via oneshot (no detached tokio::spawn).

Test plan

  • disconnect_id_shuts_down_tcp_so_far_side_sees_eof
  • disconnect_clears_far_side_getpeerinfo_within_5s
  • peerhub_register_snapshot_disconnect
  • ./scripts/ast-grep.sh
  • CI + core-functional

disconnect_id now clears the writer channel, aborts the writer task
(TCP FIN to the peer), and unregisters immediately so getpeerinfo drops
the row without waiting for the session loop. Fixes flaky
mempool_reorg disconnect_nodes (5s far-side wait). Also treat
ConnectionReset/BrokenPipe/Aborted as clean peer close.
@rearden-grok rearden-grok Bot added the core-functional Run Core functional nightly.sh on this PR (inventory + release-pin warn) label Aug 29, 2026
rbitcoin-grok[bot] added 2 commits August 29, 2026 09:34
Writer abort alone was not enough for mempool_reorg's far-side
getpeerinfo wait. Attach a session AbortHandle and abort it on
disconnect_id so reader+writer drop immediately (TCP RST/FIN).
ast-grep detached-tokio-spawn rejected the oneshot helper tasks that
installed set_session_abort. Pass the AbortHandle into the session task
instead so disconnectnode still aborts the whole session.
@rearden-grok
rearden-grok Bot force-pushed the net/disconnect-peer-prompt branch from c0b18a0 to 11a9b2d Compare August 29, 2026 16:36
mempool_reorg disconnect_nodes still flaked waiting for the far side's
getpeerinfo: aborting our session was not enough when the peer was
mid-frame. Clone the std TCP fd at open_v2 and Shutdown::Both on
disconnect_id so the far read sees EOF inside the 5s wait.
@reardencode
reardencode merged commit 681eb99 into master Aug 29, 2026
13 checks passed
@rearden-grok
rearden-grok Bot deleted the net/disconnect-peer-prompt branch August 29, 2026 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core-functional Run Core functional nightly.sh on this PR (inventory + release-pin warn)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant