Fix: Increase sync wait time for 1-connection under network latency

- Dynamically scale wait time based on latency and connection count
- 1 connection gets additional latency-proportional wait time
- Added extra sync calls after server shutdown
- Prevents verification failures due to slow disk writes under WAN conditions

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
taptap
2026-06-24 16:29:26 +02:00
parent c37e11c59f
commit 3a3482da71
+12 -4
View File
@@ -232,14 +232,22 @@ run_fastsync() {
local output
output=$(timeout 300 "$CLIENT_BIN" -h "$HOST" -p "$port" -s "$SRC_DIR" -n "$nconn" 2>&1) || true
# With network latency, wait longer for all data to be written
# 1 conn needs more time under latency
local wait_time=8
[ "$nconn" -eq 1 ] && wait_time=10
# With network latency, wait longer for all data to be written and synced to disk
# Scale wait time based on latency: base wait + (latency factor * connection count factor)
# 1 connection needs significantly more time under high latency
local base_wait=$(( LATENCY_MS * 2 / 10 ))
local conn_factor=$(( 16 / nconn ))
local wait_time=$(( base_wait + conn_factor + 5 ))
[ "$wait_time" -lt 10 ] && wait_time=10
[ "$nconn" -eq 1 ] && wait_time=$(( wait_time + LATENCY_MS / 5 + 5 ))
info "Waiting ${wait_time}s for sync to complete..."
sleep $wait_time
kill "$spid" 2>/dev/null || true
wait "$spid" 2>/dev/null || true
sync
sleep 2
sync
local ms=$(echo "$output" | grep -oP 'ms=\K[0-9.]+' || echo "0")
local mbs=$(echo "$output" | grep -oP 'throughput_mbs=\K[0-9.]+' || echo "0")