From c7624e55bbd486ba073e8cda2e1b75dcedaab505 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sat, 1 Aug 2026 02:18:13 -0700 Subject: [PATCH] test: reset phase174 flusher measurement phase --- .../replication/phase174_fixed_work_test.go | 26 +++++++++++++++++++ .../core/storage/walstore_testtools.go | 17 ++++++++++++ .../phase174-d1-fixed-work-pipeline-qa.md | 3 +++ .../run-phase174-fixed-work-pipeline-gate.sh | 6 +++-- 4 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 seaweed-block/core/storage/walstore_testtools.go diff --git a/seaweed-block/core/replication/phase174_fixed_work_test.go b/seaweed-block/core/replication/phase174_fixed_work_test.go index 371d827025..46c667d8ca 100644 --- a/seaweed-block/core/replication/phase174_fixed_work_test.go +++ b/seaweed-block/core/replication/phase174_fixed_work_test.go @@ -74,6 +74,7 @@ type phase174FixedWorkResult struct { ReplicaCount int `json:"replica_count"` ReplicaDurableCount int `json:"replica_durable_count"` ReplicaFrontiersEqual bool `json:"replica_frontiers_equal"` + FlusherPhaseReset bool `json:"flusher_phase_reset"` CloseRecoverComplete bool `json:"close_recover_complete"` CorrectnessSamples int `json:"correctness_samples"` } @@ -290,6 +291,10 @@ func runPhase174FixedWork(t *testing.T, p *phase174Pipeline, set, run, writers i if reached := p.waitForReplicaFrontier(time.Second); len(p.replicas) > 0 && reached < 1 { t.Fatal("no replica reached warmup frontier") } + flusherPhaseReset, err := p.resetFlushersForMeasurement() + if err != nil { + t.Fatalf("reset flusher phase: %v", err) + } writeBefore := p.primary.WriteInstrumentation() replicationBefore := p.replicationStats() @@ -347,6 +352,7 @@ func runPhase174FixedWork(t *testing.T, p *phase174Pipeline, set, run, writers i PrimaryStableLSN: primaryR, PrimaryHeadLSN: primaryH, ReplicaCount: len(p.replicaPaths), ReplicaDurableCount: durableReplicas, ReplicaFrontiersEqual: replicasEqual, + FlusherPhaseReset: flusherPhaseReset, CloseRecoverComplete: true, CorrectnessSamples: correctness, } if p.replication != nil { @@ -418,6 +424,26 @@ func (p *phase174Pipeline) replicationStats() VolumeStats { return p.replication.Stats() } +type phase174FlusherResetter interface { + ResetFlusherForMeasurement() error +} + +func (p *phase174Pipeline) resetFlushersForMeasurement() (bool, error) { + stores := make([]*storage.WALStore, 0, 1+len(p.replicas)) + stores = append(stores, p.primary) + stores = append(stores, p.replicas...) + for _, store := range stores { + resetter, ok := any(store).(phase174FlusherResetter) + if !ok { + return false, nil + } + if err := resetter.ResetFlusherForMeasurement(); err != nil { + return false, err + } + } + return true, nil +} + func (p *phase174Pipeline) waitForReplicaFrontier(timeout time.Duration) int { if len(p.replicas) == 0 { return 0 diff --git a/seaweed-block/core/storage/walstore_testtools.go b/seaweed-block/core/storage/walstore_testtools.go new file mode 100644 index 0000000000..8a48bcd0b4 --- /dev/null +++ b/seaweed-block/core/storage/walstore_testtools.go @@ -0,0 +1,17 @@ +//go:build swblock_testtools + +package storage + +// ResetFlusherForMeasurement restarts the default flusher from a known tick +// origin. It is available only to fixed-work test binaries built with the +// swblock_testtools tag and is never part of a shipped product binary. +func (s *WALStore) ResetFlusherForMeasurement() error { + if err := s.flusher.Stop(); err != nil { + return err + } + s.flusher = newFlusher(s, flusherConfig{}) + started := make(chan struct{}) + go s.flusher.runWithStartSignal(started) + <-started + return nil +} diff --git a/seaweed-block/internal/docs/qa-assignments/phase174-d1-fixed-work-pipeline-qa.md b/seaweed-block/internal/docs/qa-assignments/phase174-d1-fixed-work-pipeline-qa.md index e20ee888ac..8d2426a86e 100644 --- a/seaweed-block/internal/docs/qa-assignments/phase174-d1-fixed-work-pipeline-qa.md +++ b/seaweed-block/internal/docs/qa-assignments/phase174-d1-fixed-work-pipeline-qa.md @@ -39,6 +39,8 @@ overlay, or a network share. - 1,024 warmup writes in a disjoint region; - 1, 4, and 8 writers; - one final Sync, close, reopen, Recover, frontier, and byte checks; +- a build-tag-only `swblock_testtools` flusher reset after warmup, with no + control method present in shipped binaries; - two independent sets of five measured runs; - exact primary WAL and replication operation counts; - explicit `local_durable` versus `sync_quorum_rf3` ACK profiles. @@ -53,6 +55,7 @@ sample is never reused as though it were healthy in the next sample. - `cross_ack_profile_throughput_ratio_allowed=false` - all 90 measured rows reconcile 16,384 writes and 64 MiB logical data - recovered primary stable/head frontiers agree +- every row reports `flusher_phase_reset=true` - RF3 has exactly two configured replicas and at least one durable replica - direct and adapter four-writer combined max/min ranges are at most `1.25x` - `rf1_local_stability_gate=pass` diff --git a/seaweed-block/scripts/run-phase174-fixed-work-pipeline-gate.sh b/seaweed-block/scripts/run-phase174-fixed-work-pipeline-gate.sh index 42c7777908..3b861b579b 100644 --- a/seaweed-block/scripts/run-phase174-fixed-work-pipeline-gate.sh +++ b/seaweed-block/scripts/run-phase174-fixed-work-pipeline-gate.sh @@ -73,9 +73,9 @@ capture free-space df -hT "${STORE_DIR}" capture load uptime cd "${ROOT}" -go test ./core/replication -run '^TestPhase174FixedWorkContract$' -count=1 \ +go test -tags swblock_testtools ./core/replication -run '^TestPhase174FixedWorkContract$' -count=1 \ >"${ARTIFACT_DIR}/contract-test.log" 2>&1 -go test -c -o "${TEST_BINARY}" ./core/replication +go test -tags swblock_testtools -c -o "${TEST_BINARY}" ./core/replication for set_id in 1 2; do for layer in direct_walstore adapter_rf1 rf3_tcp; do @@ -132,6 +132,8 @@ for row in rows: raise SystemExit(f"bad primary write count: {row}") if row["primary_stable_lsn"] != row["primary_head_lsn"]: raise SystemExit(f"primary frontier mismatch: {row}") + if not row["flusher_phase_reset"]: + raise SystemExit(f"flusher phase was not reset: {row}") if not row["close_recover_complete"] or row["correctness_samples"] < 5: raise SystemExit(f"close/recover correctness failed: {row}") if row["foreground_ns"] <= 0 or row["final_sync_ns"] <= 0 or row["p99_ns"] <= 0: