pingqiu 6729babae5 G5-5 round 14: pre-flight stale-iptables cleanup in start_cluster
Investigation found root cause of round-13 silent failures:
M02 had a leftover INPUT DROP rule from an earlier run's
verify_network_catchup that used the OLD pattern
(`iptables -I INPUT` on M02). When that earlier run aborted via
set -e before reaching its cleanup `iptables -D`, the rule
persisted across runs. Round 13's rewrite changed to OUTPUT-on-m01
but didn't clean up the legacy INPUT-on-M02 leftover. The stale
rule blocked m01→M02:9221 ship/barrier traffic for ALL subsequent
runs; primary's peer entered degraded state on first ship attempt;
all rounds after the original poisoning incident saw the symptom
"replica daemon dies silently" because the SCRIPT's pkill found
nothing (replica had been killed by the script's own pkill but
no ship traffic ever flowed during the run).

Diagnosis sequence:
  1. ssh m01→M02:9221 TCP test: timeout (FAIL=124)
  2. m01 iptables: empty (rules out m01-side block)
  3. M02 iptables INPUT: `DROP tcp dpt:9221` (~50 dropped pkts)
  4. `iptables -D INPUT -p tcp --dport 9221 -j DROP` on M02
  5. Re-test: ssh→TCP echo OK
  6. Re-run: chain flows through to all 3 verify steps

Fix: start_cluster() now drops both possible patterns pre-flight:
  - sudo iptables -D OUTPUT -d  -p tcp --dport  -j DROP   (round-13 pattern)
  - sudo iptables -D INPUT -p tcp --dport  -j DROP                 (round-12 leftover)
Both with || true so missing rules don't fail set -e.

Round-14 result on m01:
  ✓ verify_cluster_ready
  ✓ verify_byte_equal       (LBA[0]=0xab)
  ✓ verify_network_catchup  (LBA[1]=0xcd byte-equal in 8s after iptables disconnect+heal)
  ✗ verify_restart_catchup  (LBA[2]=0xef MISMATCH — real recovery-path finding)

The verify_restart_catchup failure is exactly the case architect
ruling 2 named: 'run #4 naively first; if it doesn't converge,
that is a real recovery-path finding to surface, not a test flaw.'

Primary's log evidence:
  After replica killed → ship attempt → barrier timeout → peer
  invalidated (degraded). Primary writes LBA[2]=0xef while replica
  down → 'ship gate-degraded peer=r2 lba=2 lsn=3 (peer degraded)'
  — ship is gated out before any TCP attempt. Replica restarts;
  no mechanism triggers primary to re-establish the peer
  connection or re-ship the missed entries.

Architecturally the engine-driven catch-up path needs a trigger
(probe success, assignment re-emit, etc.) to bring a degraded
peer back online + replay missed LSNs. G5-5 surfaces that this
trigger isn't wired into the binary's runtime — surface for
architect / QA decision: (a) defer #4 to a follow-up batch with
a dedicated peer-recovery fix; (b) implement now within G5-5
scope.

Refs: round 14 m01 self-iteration; investigation traced 4
indirection layers to find the leftover iptables rule.
2026-04-27 02:15:22 -07:00
Languages
Go 84.7%
Rust 7.7%
Shell 2.7%
templ 1.5%
Java 1%
Other 2.1%