mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-06 11:07:31 +01:00
test: trace forced-move deliveries and reject stale self replay
This commit is contained in:
1 parent
9f54c4f155
commit
22037e1ce5
2 files changed
+42
-3
No files matched your search
@@ -242,3 +242,39 @@ func TestAssignmentHolderIdentityForeignStreamOrdering(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// INV-AUTH-HOLDER-IDENTITY-001: an old process cannot adopt a stale
|
||||
// self-labelled EV1 after it has observed the forced move's foreign EV2.
|
||||
func TestAssignmentHolderIdentityForcedMoveRefusesEveryDeliveredVersion(t *testing.T) {
|
||||
h, err := New(Config{MasterAddr: "127.0.0.1:1", ServerID: "old-host", VolumeID: "v1", ReplicaID: "r1", DataAddr: "127.0.0.1:19303", CtrlAddr: "127.0.0.1:19304", EnableT1Readiness: true})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { _ = h.Close() })
|
||||
h.BlockLocalReadiness("awaiting durable recovery")
|
||||
for _, ev := range []uint64{1, 2, 1, 3} {
|
||||
foreign := holderAssignment(t, "new-host")
|
||||
foreign.EndpointVersion = ev
|
||||
h.applyFact(foreign)
|
||||
if h.realAdpt.Projection().Epoch != 0 {
|
||||
t.Fatalf("old server adopted foreign EV%d", ev)
|
||||
}
|
||||
}
|
||||
// Covers the safety boundary even if an older delivery incorrectly
|
||||
// names the source: a known newer foreign line still takes precedence.
|
||||
staleSelf := holderAssignment(t, "old-host")
|
||||
h.applyFact(staleSelf)
|
||||
h.ClearLocalReadinessBlock()
|
||||
h.replayLocalReadinessFactIfReady()
|
||||
if p := h.realAdpt.Projection(); p.Epoch != 0 {
|
||||
t.Fatalf("old server adopted stale EV1 after foreign newer line: %+v", p)
|
||||
}
|
||||
for _, cmd := range h.t1exec.Commands() {
|
||||
if strings.HasPrefix(cmd, "PublishHealthy:") {
|
||||
t.Fatalf("old server published healthy: %s", cmd)
|
||||
}
|
||||
}
|
||||
if h.view.Projection().Healthy {
|
||||
t.Fatal("old server served after forced move")
|
||||
}
|
||||
}
|
||||
@@ -396,7 +396,8 @@ func (h *Host) replayLocalReadinessFactIfReady() {
|
||||
if fact == nil {
|
||||
return
|
||||
}
|
||||
h.log.Printf("blockvolume: volume %s replaying assignment after local readiness cleared", h.cfg.VolumeID)
|
||||
h.log.Printf("blockvolume: volume %s replaying assignment after local readiness cleared server=%q epoch=%d ev=%d data=%q ctrl=%q",
|
||||
h.cfg.VolumeID, fact.ServerId, fact.Epoch, fact.EndpointVersion, fact.DataAddr, fact.CtrlAddr)
|
||||
h.applyFact(fact)
|
||||
}
|
||||
|
||||
@@ -779,6 +780,8 @@ func (h *Host) streamOnce(ctx context.Context) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
h.log.Printf("blockvolume: assignment stream delivery process=%q server=%q volume=%q replica=%q epoch=%d ev=%d data=%q ctrl=%q",
|
||||
h.cfg.ServerID, fact.ServerId, fact.VolumeId, fact.ReplicaId, fact.Epoch, fact.EndpointVersion, fact.DataAddr, fact.CtrlAddr)
|
||||
h.applyFact(fact)
|
||||
}
|
||||
}
|
||||
@@ -931,8 +934,8 @@ func (h *Host) applyFact(fact *control.AssignmentFact) {
|
||||
return
|
||||
}
|
||||
h.adpt.OnAssignment(info)
|
||||
h.log.Printf("blockvolume: volume %s adopted as PRIMARY at %s@%d (EV=%d)",
|
||||
h.cfg.VolumeID, info.ReplicaID, info.Epoch, info.EndpointVersion)
|
||||
h.log.Printf("blockvolume: volume %s adopted as PRIMARY at %s@%d (EV=%d) process=%q server=%q data=%q ctrl=%q",
|
||||
h.cfg.VolumeID, info.ReplicaID, info.Epoch, info.EndpointVersion, h.cfg.ServerID, fact.ServerId, fact.DataAddr, fact.CtrlAddr)
|
||||
if h.cfg.ReadyMarker != nil && info.Epoch > 0 && h.readyOnce.CompareAndSwap(false, true) {
|
||||
select {
|
||||
case h.cfg.ReadyMarker <- info:
|
||||
|
||||
Reference in new issue
Block a user