pyln-testing: wait for listen port release before starting a node#9355
Open
ksedgwic wants to merge 1 commit into
Open
pyln-testing: wait for listen port release before starting a node#9355ksedgwic wants to merge 1 commit into
ksedgwic wants to merge 1 commit into
Conversation
A node's connectd is a separate process holding the listen socket, and on shutdown it exits on its own schedule after lightningd itself is gone -- under valgrind, its teardown can lag by tens of seconds. If a test restarts the node in that window, the new connectd fails with 'Address already in use', lightningd exits, and the test times out waiting for 'Server started with public key'. Seen in CI in test_emergencyrecoverpenaltytxn, where the port was still held 37 seconds after the old connectd began shutting down. The filesystem port locks don't cover this: they keep other workers from reserving the port, but the restarting node owns its reservation both times; nothing waits for the old connectd to actually release the socket. Before launching lightningd, bind-probe the node's port (with SO_REUSEADDR, matching connectd, so TIME_WAIT sockets don't count as in use) and only proceed once the bind succeeds. Fixes: ElementsProject#9354 Changelog-None
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.
Fixes #9354 : when a test restarts a node, the previous connectd --
slow to exit under valgrind -- can still hold the listen socket, so
the new connectd fails with 'Address already in use' and the test
times out waiting for 'Server started with public key'.
Before launching lightningd, bind-probe the node's port with
SO_REUSEADDR and wait until the bind succeeds.
Validated by holding a stopped node's port from the test process and
restarting: without this change that reproduces the CI failure
exactly (same BROKEN bind message and timeout); with it, start waits
out the holder and proceeds.
Changelog-None