Skip to content

Commit beec5b7

Browse files
author
michael stack
committed
Fix port retry in fdb_cluster_fixture by grepping stderr separately
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.
1 parent 043ec0b commit beec5b7

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

fdbclient/tests/fdb_cluster_fixture.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ function start_fdb_cluster {
136136
--storage_count "${ss_count}" --storage_type ssd-rocksdb-v1 \
137137
--dump_pids on \
138138
> >(tee "${output}") \
139-
2> >(tee "${output}" >&2)
139+
2> >(tee "${output}.stderr" >&2)
140140
status="$?"
141141
# Restore exit on error.
142142
set -o errexit # a.k.a. set -e
@@ -171,13 +171,14 @@ function start_fdb_cluster {
171171
fi
172172
break;
173173
fi
174-
# Otherwise, look for 'Local address in use' and if found retry with different ports.
175-
# Use grep -a to treat binary files as text
176-
if grep -a 'Local address in use' "${output}"; then
177-
log "Ports in use; retry cluster start but with different ports"
174+
# Check stderr (separate file to avoid tee process substitution race) for
175+
# port-in-use error. Only retry on port collision; fail on anything else.
176+
if grep -a 'Local address in use' "${output}.stderr"; then
177+
log "Port ${port_prefix} in use, retrying with next port"
178178
continue
179179
fi
180-
err "Failed to start fdb cluster"
180+
err "Failed to start fdb cluster (stderr follows):"
181+
cat "${output}.stderr" >&2
181182
return 1
182183
done
183184
}

0 commit comments

Comments
 (0)