mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 10:07:28 +01:00
test(replication): pin WAL across both two-replica catch-up sessions
This commit is contained in:
1 parent
d4ebc48ef7
commit
80ba50dfd2
1 file changed
+29
@@ -110,14 +110,43 @@ func TestComponent_ProbeHappy(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
// Pin the genesis replay window across both sessions. Unlike a logical
|
||||
// retention setting, this prevents the old impl1 checkpoint releasing it.
|
||||
type twoReplicaWALPin struct{}
|
||||
|
||||
func (twoReplicaWALPin) MinPinAcrossActiveSessions() (uint64, bool) { return 0, true }
|
||||
|
||||
// TestComponent_TwoReplicas_BothConverge — multi-replica scenario.
|
||||
// Demonstrates WithReplicas(N) + per-replica catch-up.
|
||||
func TestComponent_TwoReplicas_BothConverge(t *testing.T) {
|
||||
component.RunMatrix(t, func(t *testing.T, c *component.Cluster) {
|
||||
c.WithReplicas(2).Start()
|
||||
var ws *storage.WALStore
|
||||
var priorFlushes uint64
|
||||
if s, ok := c.Primary().Store.(*storage.WALStore); ok {
|
||||
ws, priorFlushes = s, s.FlushCount()
|
||||
s.SetRecycleFloorSource(twoReplicaWALPin{})
|
||||
defer s.SetRecycleFloorSource(nil)
|
||||
}
|
||||
|
||||
c.PrimaryWriteN(10)
|
||||
c.PrimarySync()
|
||||
|
||||
// Let the real flusher complete work before catch-up, so the pin
|
||||
// (rather than winning a race with the timer) keeps WAL available.
|
||||
if ws != nil {
|
||||
deadline := time.Now().Add(10 * time.Second)
|
||||
for ws.FlushCount() == priorFlushes && time.Now().Before(deadline) {
|
||||
time.Sleep(time.Millisecond)
|
||||
}
|
||||
if ws.FlushCount() == priorFlushes {
|
||||
t.Fatal("primary did not complete a flush")
|
||||
}
|
||||
if cp := ws.CheckpointLSN(); cp != 0 {
|
||||
t.Fatalf("active replay pin allowed checkpoint%d, want0", cp)
|
||||
}
|
||||
}
|
||||
|
||||
for i := 0; i < c.ReplicaCount(); i++ {
|
||||
r := c.CatchUpReplica(i)
|
||||
if !r.Success {
|
||||
|
||||
Reference in new issue
Block a user