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:
+12
-4
@@ -232,14 +232,22 @@ run_fastsync() {
|
|||||||
local output
|
local output
|
||||||
output=$(timeout 300 "$CLIENT_BIN" -h "$HOST" -p "$port" -s "$SRC_DIR" -n "$nconn" 2>&1) || true
|
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
|
# With network latency, wait longer for all data to be written and synced to disk
|
||||||
# 1 conn needs more time under latency
|
# Scale wait time based on latency: base wait + (latency factor * connection count factor)
|
||||||
local wait_time=8
|
# 1 connection needs significantly more time under high latency
|
||||||
[ "$nconn" -eq 1 ] && wait_time=10
|
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
|
sleep $wait_time
|
||||||
kill "$spid" 2>/dev/null || true
|
kill "$spid" 2>/dev/null || true
|
||||||
wait "$spid" 2>/dev/null || true
|
wait "$spid" 2>/dev/null || true
|
||||||
sync
|
sync
|
||||||
|
sleep 2
|
||||||
|
sync
|
||||||
|
|
||||||
local ms=$(echo "$output" | grep -oP 'ms=\K[0-9.]+' || echo "0")
|
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")
|
local mbs=$(echo "$output" | grep -oP 'throughput_mbs=\K[0-9.]+' || echo "0")
|
||||||
|
|||||||
Reference in New Issue
Block a user