Skip to content

test: fix race in connect_tests disconnect-deferred-failure test - #343

Open
ryanofsky wants to merge 1 commit into
bitcoin-core:masterfrom
ryanofsky:pr/disflake
Open

test: fix race in connect_tests disconnect-deferred-failure test#343
ryanofsky wants to merge 1 commit into
bitcoin-core:masterfrom
ryanofsky:pr/disflake

Conversation

@ryanofsky

Copy link
Copy Markdown
Collaborator

This fixes an intermittent mptest failure which is a regression from #308. Commit bb47369 introduced a test with a race condition where there the test could trigger two different exceptions depending on when the client onDisconnect handler ran, and only one of the exceptions was being checked for in the test. If the onDisconnect handler ran later, the test would fail.

The "ConnectStream defers disconnect failure" test was flaky: there is a
race between the event loop detecting the disconnect and foo->add() being
called. If the onDisconnect callback fires first and nulls
m_context.connection, the error is "called after disconnect"; if
foo->add() submits before the callback fires, the error is "interrupted
by disconnect". Accept both, with a comment explaining the race.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@DrahtBot

DrahtBot commented Aug 13, 2026

Copy link
Copy Markdown

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Reviews

See the guideline and AI policy for information on the review process.

Type Reviewers
ACK xyzconstant

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

@xyzconstant

Copy link
Copy Markdown
Contributor

ACK 137a6e4

I couldn't reproduce the "IPC client method call interrupted by disconnect." path locally, so I'm curious what circumstances trigger it. In any case the changes look good to me, nice comment explaining the race.

@ryanofsky

Copy link
Copy Markdown
Collaborator Author

I couldn't reproduce the "IPC client method call interrupted by disconnect." path locally.

I think it might help to have a slower machine, since it happens when the event loop thread is slow to process the disconnect. Some failures from bitcoin/bitcoin#32387 were

https://github.com/bitcoin/bitcoin/actions/runs/31655880824/job/94310097312
https://github.com/bitcoin/bitcoin/actions/runs/31655880824/job/94310097504
https://github.com/bitcoin/bitcoin/actions/runs/31655880824/job/94310097306
https://github.com/bitcoin/bitcoin/actions/runs/31655880824/job/94310097431
https://github.com/bitcoin/bitcoin/actions/runs/31655880824/job/94310097386

@xyzconstant

Copy link
Copy Markdown
Contributor

I think it might help to have a slower machine, since it happens when the event loop thread is slow to process the disconnect. Some failures from bitcoin/bitcoin#32387 were

That makes sense, thanks!

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.

3 participants