mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 18:17:16 +01:00
20d04965d9fc20b2c04c481efcc1f090c7d49670
QA round 53 finding (Tier 2 m01 → M02): start_replica's SSH session
hung even on Linux (m01 native ssh, no Windows-Git-Bash quirks).
Root cause is a `\<newline>` line-collapse hazard in the
double-quoted SSH command argument:
$SSH_LAUNCH_M02 "
setsid nohup /tmp/g5-blockvolume \
--master ... \
...
> .../replica.log 2>&1 </dev/null &
disown \$! 2>/dev/null || true
sleep 1
exit 0"
The local shell processes `\<newline>` as line continuation INSIDE
the double-quoted string. The `\` at end of every option line
collapses lines, which can in some bash interactions produce a
joined argv where `&` runs into `disown` directly with no
separator. Remote bash then parses the joined statement
incorrectly, never executes `disown $!` / `sleep 1` / `exit 0`,
remains attached to the bg daemon, and SSH hangs.
The `\<newline>` substitution happens in the LOCAL shell (the one
running iterate.sh), so it's not Windows-Git-Bash-specific —
reproduces on m01 (Linux) too.
Fix per architect option (A) round 53: pipe the command body to
remote bash via `bash -s` heredoc instead of double-quoted ssh
argument.
launch_m01 <<EOF
setsid nohup CMD ARG1 ARG2 ... > LOG 2>&1 </dev/null &
disown \$! 2>/dev/null || true
sleep 1
exit 0
EOF
With heredoc + `bash -s`:
- body is piped to remote bash's stdin verbatim
- newlines are preserved literally regardless of any local
shell processing
- statement boundaries are unambiguous
- daemon command on a single line (no `\<newline>` continuations)
eliminates the entire ambiguity class
Implementation:
- new launch_m01() / launch_m02() functions handle Tier 1
(LOCAL_MODE=1, run via local `bash -s`) and Tier 2 (run via
`ssh ... bash -s`) with shared timeout-prefix logic
- start_master / start_primary / start_replica use the new
helpers + heredoc body
- removed SSH_LAUNCH_M01 / SSH_LAUNCH_M02 vars (subsumed by
launch_m01 / launch_m02)
Verified: local Tier-1-style smoke test launches a `sleep 30` bg
process, disowns it, and exits within 1.08s (the explicit `sleep
1` + overhead). Pre-fix this took ~5s (timeout fallback). The bg
process detached and ran independently. This proves all three
post-`&` statements (disown / sleep / exit) execute as separate
commands — the line-collapse hazard is structurally eliminated.
Refs: QA Tier 2 round 53 finding (Linux SSH hang); architect
option (A) ratified; option (B) `;<newline>` rejected per QA's
clarification (newlines also stripped by `\<newline>` so
semicolons alone don't help).
Languages
Go
84.5%
Rust
7.9%
Shell
2.7%
templ
1.6%
Java
1%
Other
2%