test: reset phase174 flusher measurement phase

This commit is contained in:
pingqiu committed 2026-08-01 02:18:13 -07:00
1 parent d427ed8efa
commit c7624e55bb
4 files changed
+50 -2

No files matched your search

@@ -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
@@ -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
}
@@ -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`
@@ -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: