Make port collision detection more robust in fdb_cluster_fixture#13249
Conversation
There was a problem hiding this comment.
Pull request overview
This PR reduces CI flakiness in blob_backup_restore_tests by allowing the fdb_cluster_fixture.sh loopback cluster startup to retry more port ranges when initial ports are already in use on busy runners.
Changes:
- Add a bounded retry counter (up to 20 attempts) when restarting the loopback cluster on “Local address in use”.
- Emit a failure message when no free port range is found after exhausting retries.
| local port_prefix=1500 | ||
| local max_port_retries=20 | ||
| local port_attempt=0 | ||
| while : ; do | ||
| port_prefix="$(( port_prefix + 100 ))" | ||
| port_attempt="$(( port_attempt + 1 ))" | ||
| if (( port_attempt > max_port_retries )); then | ||
| err "Failed to find available ports after ${max_port_retries} attempts (tried ports ${1600}..${port_prefix})" |
There was a problem hiding this comment.
Yeah, you just want to replace tried ports ${1600}.. with tried ports 1600..
There was a problem hiding this comment.
(I think it would make things more elegant if the port_prefix was increased just before the continue, rather than at the beginning of the loop. Not a big deal though.)
|
@saintstack Fix looks good to me. one bug tho Line 124: Also worth noting: when the guard fires, Otherwise the approach is solid bounded retry with a clear failure message is exactly the right fix here. |
Result of foundationdb-pr-clang-ide on Linux RHEL 9
|
Result of foundationdb-pr-macos-m1 on macOS Ventura 13.x
|
I actually don't see where it would give up after 2 attempts, before? |
Result of foundationdb-pr-clang-arm on Linux CentOS 7
|
Result of foundationdb-pr-macos on macOS Ventura 13.x
|
Result of foundationdb-pr on Linux RHEL 9
|
Result of foundationdb-pr-clang on Linux RHEL 9
|
Result of foundationdb-pr-cluster-tests on Linux RHEL 9
|
|
@saintstack looks good to me |
Result of foundationdb-pr-macos on macOS Ventura 13.x
|
Result of foundationdb-pr-clang-ide on Linux RHEL 9
|
|
Thank you for review @Ronitsabhaya75 . Addressed.
@ploxiln Good one. It's been reliable up to this. It depends on this grep ' 184 if grep -a 'Local address in use' "${output}"; then' working properly. I've found since that ctest grepping outputs can be flakey/interrupted/overwritten. Thought explicit counter 'safer' but you remind me that elsewhere I've moved to clearer what we grep. Let me apply that philosophy here too.. just grep the stderr stream (issue seems to be interleaving here though not plain from review of the log -- will print string we fail on going forward.). |
|
This failure is not the same ctest #13249 (comment) |
Result of foundationdb-pr-macos-m1 on macOS Ventura 13.x
|
The blob_backup_restore_tests ctest fails on busy CI instances when ports are already in use by parallel tests. The existing loop retried on port-in-use errors by grepping the output file for 'Local address in use', but both stdout and stderr were tee'd to the same output file via async process substitution, causing races where the grep misses the error string and the loop exits prematurely. Fix: tee stderr to a separate file (output.stderr) so the grep for 'Local address in use' is reliable and not corrupted by interleaved stdout. Non-port-in-use failures still fail immediately with stderr printed for debugging.
Result of foundationdb-pr-clang on Linux RHEL 9
|
Result of foundationdb-pr-clang-arm on Linux CentOS 7
|
Result of foundationdb-pr-clang-arm on Linux CentOS 7
|
Result of foundationdb-pr-macos-m1 on macOS Ventura 13.x
|
Result of foundationdb-pr-cluster-tests on Linux RHEL 9
|
Result of foundationdb-pr on Linux RHEL 9
|
Result of foundationdb-pr-macos on macOS Ventura 13.x
|
Result of foundationdb-pr-clang on Linux RHEL 9
|
Result of foundationdb-pr-clang on Linux RHEL 9
|
Result of foundationdb-pr-clang-ide on Linux RHEL 9
|
Result of foundationdb-pr-macos-m1 on macOS Ventura 13.x
|
Result of foundationdb-pr-macos on macOS Ventura 13.x
|
Result of foundationdb-pr-clang-arm on Linux CentOS 7
|
Result of foundationdb-pr on Linux RHEL 9
|
Result of foundationdb-pr-clang on Linux RHEL 9
|
Result of foundationdb-pr-cluster-tests on Linux RHEL 9
|
Replace process substitution with tee with plain file redirects. The tee was unnecessary since neither stream needs real-time terminal output: stdout is only grepped for PIDs and stderr is only checked for port collisions or dumped on failure.
Result of foundationdb-pr-cluster-tests on Linux RHEL 9
|
Result of foundationdb-pr-clang-ide on Linux RHEL 9
|
Result of foundationdb-pr-clang-arm on Linux CentOS 7
|
Result of foundationdb-pr-macos-m1 on macOS Ventura 13.x
|
Result of foundationdb-pr-clang on Linux RHEL 9
|
Result of foundationdb-pr on Linux RHEL 9
|
Result of foundationdb-pr-macos on macOS Ventura 13.x
|
Result of foundationdb-pr-cluster-tests on Linux RHEL 9
|
|
Thanks for the reviews @ploxiln and @Ronitsabhaya75 . In particular Pierce, the questions which made final change simpler, clearer. |
This ctest failed in last night's nightly run. The blob_backup_restore_tests ctest fails on busy CI instances when ports are already in use by parallel tests. The existing loop retried on port-in-use errors by grepping the output file for 'Local address in use', but both stdout and stderr were tee'd to the same output file via async process substitution, causing races where the grep misses the error string and the loop exits prematurely.
Fix: tee stderr to a separate file (output.stderr) so the grep for 'Local address in use' is reliable and not corrupted by interleaved stdout. Non-port-in-use failures still fail immediately with stderr printed for debugging.
Here is from the nightly failure (mocks3 retries a few ports and so does fdb but it only tries two ports.... before failing)