mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-11-17 09:17:39 +01:00
refactor: widen bounded multi-replica catch-up startup ownership
Emit one core-owned start_recovery_task per primary catch-up replica so the bounded multi-replica startup path no longer depends on a single-replica assumption. Made-with: Cursor
This commit is contained in:
1 parent
92c006eb29
commit
5fd9ec0edf
6 files changed
+274
-7
No files matched your search
@@ -29,6 +29,35 @@ func TestPhase14_CommandSequence_PrimaryAssignmentIsBounded(t *testing.T) {
|
||||
assertCommandNames(t, result.Commands, nil)
|
||||
}
|
||||
|
||||
func TestPhase14_CommandSequence_PrimaryMultiReplicaAssignmentStartsRecoveryPerReplica(t *testing.T) {
|
||||
core := NewCoreEngine()
|
||||
ev := AssignmentDelivered{
|
||||
ID: "vol-cmd-primary-multi",
|
||||
Epoch: 1,
|
||||
Role: RolePrimary,
|
||||
RecoveryTarget: SessionCatchUp,
|
||||
Replicas: []ReplicaAssignment{
|
||||
{ReplicaID: "replica-1", Endpoint: Endpoint{DataAddr: "10.0.0.21:9333", CtrlAddr: "10.0.0.21:9334", Version: 1}},
|
||||
{ReplicaID: "replica-2", Endpoint: Endpoint{DataAddr: "10.0.0.22:9333", CtrlAddr: "10.0.0.22:9334", Version: 1}},
|
||||
},
|
||||
}
|
||||
|
||||
result := core.ApplyEvent(ev)
|
||||
assertCommandNames(t, result.Commands, []string{
|
||||
"apply_role",
|
||||
"configure_shipper",
|
||||
"start_recovery_task",
|
||||
"start_recovery_task",
|
||||
"publish_projection",
|
||||
})
|
||||
if got := recoveryTaskReplicaIDs(result.Commands); !reflect.DeepEqual(got, []string{"replica-1", "replica-2"}) {
|
||||
t.Fatalf("recovery task replicas=%v", got)
|
||||
}
|
||||
|
||||
result = core.ApplyEvent(ev)
|
||||
assertCommandNames(t, result.Commands, nil)
|
||||
}
|
||||
|
||||
func TestPhase14_CommandSequence_ReplicaAssignmentIsBounded(t *testing.T) {
|
||||
core := NewCoreEngine()
|
||||
ev := AssignmentDelivered{
|
||||
@@ -270,3 +299,15 @@ func assertCommandNames(t *testing.T, cmds []Command, want []string) {
|
||||
t.Fatalf("commands=%v, want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func recoveryTaskReplicaIDs(cmds []Command) []string {
|
||||
var replicaIDs []string
|
||||
for _, cmd := range cmds {
|
||||
start, ok := cmd.(StartRecoveryTaskCommand)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
replicaIDs = append(replicaIDs, start.ReplicaID)
|
||||
}
|
||||
return replicaIDs
|
||||
}
|
||||
Reference in new issue
Block a user