mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-05-22 17:51:30 +00:00
Rebuild session protocol implementation for v2-rebuild-mvp-session-protocol.md. New files: - rebuild_bitmap.go: RebuildBitmap — session-scoped dense bitset for WAL-applied LBA tracking. MarkApplied on local WAL write (not receive). ShouldApplyBase returns false for WAL-covered LBAs (WAL always wins). - rebuild_session.go: RebuildSession — replica-side two-line rebuild. WAL lane (ApplyWALEntry) + base lane (ApplyBaseBlock) with bitmap conflict resolution. TryComplete requires BOTH base_complete AND wal_applied_lsn >= target_lsn. Volume-level control surface: StartRebuildSession, ApplyRebuildSessionWALEntry/BaseBlock, MarkRebuildSessionBaseComplete, TryCompleteRebuildSession, CancelRebuildSession, ActiveRebuildSession. - rebuild_mvp_test.go: 4 correctness tests — base+WAL converge, WAL-applied never overwritten by base, bitmap set on applied not received, control surface start/supersede/complete. - rebuild_transport_test.go: 2 transport-level tests — two-line with real WAL shipping, live writes during base copy with bitmap conflict. Design docs: - v2-rebuild-mvp-session-protocol.md: MVP spec with message set, apply rules, completion/failure/crash rules, test matrix - v2-sync-recovery-protocol.md: full protocol context (keepup/catchup/ rebuild unified design, primary decision logic, two-line model) - v2-session-protocol-shape.md: protocol shape overview Protocol engine (reference, not production): - sw-block/protocol/: 7-event engine with ~300 lines, 13 tests 6 rebuild tests pass, all existing component tests pass. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
79 lines
1.9 KiB
Go
79 lines
1.9 KiB
Go
package replication
|
|
|
|
// Command is one side-effect-free decision emitted by the Phase 14 core skeleton.
|
|
// Adapters execute commands later; the core only decides them.
|
|
type Command interface {
|
|
commandName() string
|
|
}
|
|
|
|
type ApplyRoleCommand struct {
|
|
VolumeID string
|
|
Epoch uint64
|
|
Role VolumeRole
|
|
}
|
|
|
|
func (ApplyRoleCommand) commandName() string { return "apply_role" }
|
|
|
|
type StartReceiverCommand struct {
|
|
VolumeID string
|
|
}
|
|
|
|
func (StartReceiverCommand) commandName() string { return "start_receiver" }
|
|
|
|
type ConfigureShipperCommand struct {
|
|
VolumeID string
|
|
Replicas []ReplicaAssignment
|
|
}
|
|
|
|
func (ConfigureShipperCommand) commandName() string { return "configure_shipper" }
|
|
|
|
type StartRecoveryTaskCommand struct {
|
|
VolumeID string
|
|
ReplicaID string
|
|
Kind SessionKind
|
|
}
|
|
|
|
// StartRecoveryTaskCommand realizes the primary-owned session executor for one
|
|
// replica after assignment has established membership.
|
|
func (StartRecoveryTaskCommand) commandName() string { return "start_recovery_task" }
|
|
|
|
type DrainRecoveryTaskCommand struct {
|
|
VolumeID string
|
|
ReplicaID string
|
|
Reason string
|
|
}
|
|
|
|
func (DrainRecoveryTaskCommand) commandName() string { return "drain_recovery_task" }
|
|
|
|
type StartCatchUpCommand struct {
|
|
VolumeID string
|
|
ReplicaID string
|
|
TargetLSN uint64
|
|
}
|
|
|
|
func (StartCatchUpCommand) commandName() string { return "start_catchup" }
|
|
|
|
type StartRebuildCommand struct {
|
|
VolumeID string
|
|
ReplicaID string
|
|
TargetLSN uint64
|
|
}
|
|
|
|
func (StartRebuildCommand) commandName() string { return "start_rebuild" }
|
|
|
|
type InvalidateSessionCommand struct {
|
|
VolumeID string
|
|
ReplicaID string
|
|
Reason string
|
|
}
|
|
|
|
func (InvalidateSessionCommand) commandName() string { return "invalidate_session" }
|
|
|
|
type PublishProjectionCommand struct {
|
|
VolumeID string
|
|
Projection PublicationProjection
|
|
}
|
|
|
|
// PublishProjectionCommand emits the derived outward summary for the volume.
|
|
func (PublishProjectionCommand) commandName() string { return "publish_projection" }
|