diff --git a/seaweed-block/core/replication/component/cluster.go b/seaweed-block/core/replication/component/cluster.go index 013fbc956b..6bb1849535 100644 --- a/seaweed-block/core/replication/component/cluster.go +++ b/seaweed-block/core/replication/component/cluster.go @@ -459,7 +459,17 @@ func (c *Cluster) Start() *Cluster { executors := make([]*transport.BlockExecutor, c.replicaN) for i, r := range c.replicas { if c.dualLane { - rid := recovery.ReplicaID(fmt.Sprintf("r-%d", i)) + // INV-RID-UNIFIED-PER-SESSION: the construction RID MUST + // match the engine driver's per-replica ID (the arg flowing + // through StartRebuild). Engine driver convention here is + // "replica-%d" — see the AssignmentInfo / ProbeResult + // callsites in dual_lane_engine_test.go and the + // VolumeReplicaAdapter's keying. Pre-Phase-0-Fix-#1 this + // was "r-%d", which silently diverged: bridge keyed coord + // under "r-N" while sink keyed under "replica-N". The + // startRebuildDualLane assert now fails closed on that + // mismatch. + rid := recovery.ReplicaID(fmt.Sprintf("replica-%d", i)) executors[i] = transport.NewBlockExecutorWithDualLane( pStore, r.Addr, r.DualLaneAddr, c.coord, rid, ) diff --git a/seaweed-block/core/replication/component/dual_lane_engine_test.go b/seaweed-block/core/replication/component/dual_lane_engine_test.go index 6f052555cb..ffe5e52329 100644 --- a/seaweed-block/core/replication/component/dual_lane_engine_test.go +++ b/seaweed-block/core/replication/component/dual_lane_engine_test.go @@ -107,7 +107,11 @@ func TestDualLane_EngineDrivenRebuild_HappyPath(t *testing.T) { } // Coordinator should be back to Idle for replica-0. - if got := c.Coord().Phase(recovery.ReplicaID("r-0")); got != recovery.PhaseIdle { + // Phase-0-Fix-#1 INV-RID-UNIFIED-PER-SESSION: the engine arg + // flowing through StartRebuild is "replica-0"; the bridge now + // keys coord under that arg. (Pre-fix this was "r-0", + // matching the cluster harness's stale construction RID.) + if got := c.Coord().Phase(recovery.ReplicaID("replica-0")); got != recovery.PhaseIdle { t.Errorf("coord phase post-session: %s want Idle", got) } @@ -190,7 +194,8 @@ func TestDualLane_CoordReleasesPinFloorAfterSession(t *testing.T) { if _, anyActive := c.Coord().MinPinAcrossActiveSessions(); anyActive { t.Errorf("post-session: MinPinAcrossActiveSessions still reports anyActive=true") } - if got := c.Coord().PinFloor(recovery.ReplicaID("r-0")); got != 0 { + // Phase-0-Fix-#1: keyed under the engine arg "replica-0" (was "r-0"). + if got := c.Coord().PinFloor(recovery.ReplicaID("replica-0")); got != 0 { t.Errorf("post-session: PinFloor=%d want 0 (released)", got) } }) @@ -246,7 +251,10 @@ func TestDualLane_EngineDrivenRebuild_WithPushLiveDuringSession(t *testing.T) { t.Fatal("BlockExecutor missing dual-lane PrimaryBridge") } - // PeerShipCoordinator keys match NewBlockExecutorWithDualLane replica id ("r-0"). + // PeerShipCoordinator keys match NewBlockExecutorWithDualLane replica id + // ("replica-0" post-Phase-0-Fix-#1). DualLanePrimaryBridge() returns the + // construction RID, which now agrees with the engine arg per + // INV-RID-UNIFIED-PER-SESSION. if c.Coord().Phase(coordRID) == recovery.PhaseIdle { t.Fatal("coord still Idle after rebuild dispatch — PushLiveWrite would fail") }