mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-06 02:57:37 +01:00
transport: the barrier reply carries the first LSN of the replica's last data epoch, and the primary requires it to match
Two tables can agree on an epoch number and still describe different histories: a survivor whose epoch 2 starts at 7 (an old tail 5..6 kept) read as in sync with a primary whose epoch 2 starts at 5. The reply is 56 bytes (40 from a replica without the table); SharedEnd takes the replica's (epoch, first LSN, end) and a different first LSN is diverged. A rebuild whose table replace fails is not acknowledged, and the stale table reconciles as diverged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0c03f41fda
commit
e42597ce1d
12 files changed
+134
-47
No files matched your search
@@ -88,3 +88,15 @@ func TestPromotionSeed_EpochTableControls(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// The receiver check: both tables end at epoch 2, but the survivor's epoch 2
|
||||
// starts at 7 (it kept an old tail 5..6), the primary's at 5. The epoch
|
||||
// number alone reads in sync; its first LSN does not.
|
||||
func TestPromotionSeed_SameEpochStartingElsewhereIsRebuilt(t *testing.T) {
|
||||
got := seedWithTables(t, 8,
|
||||
[]transport.EpochRow{{Epoch: 1, FirstLSN: 1}, {Epoch: 2, FirstLSN: 7}},
|
||||
[]transport.EpochRow{{Epoch: 1, FirstLSN: 1}, {Epoch: 2, FirstLSN: 5}})
|
||||
if got != ReplicaNeedsRebuild {
|
||||
t.Fatalf("peer state %s; want needs_rebuild for epoch 2 starting at 7 against 5", got)
|
||||
}
|
||||
}
|
||||
@@ -345,10 +345,10 @@ func TestT4b6_BarrierWire_FullLineageEcho_StillEnforced(t *testing.T) {
|
||||
},
|
||||
AchievedLSN: 99,
|
||||
}
|
||||
sample.LastDataEpoch = 7
|
||||
sample.LastDataEpoch, sample.LastDataFirstLSN = 7, 31
|
||||
encoded := transport.EncodeBarrierResp(sample)
|
||||
if len(encoded) != 48 {
|
||||
t.Fatalf("BarrierResp encoded length = %d; wire shape (48B = 32B lineage + 8B achievedLSN + 8B lastDataEpoch) regressed",
|
||||
if len(encoded) != 56 {
|
||||
t.Fatalf("BarrierResp encoded length = %d; wire shape (56B = 32B lineage + 8B achievedLSN + 8B lastDataEpoch + 8B lastDataFirstLSN) regressed",
|
||||
len(encoded))
|
||||
}
|
||||
|
||||
@@ -362,16 +362,18 @@ func TestT4b6_BarrierWire_FullLineageEcho_StillEnforced(t *testing.T) {
|
||||
if got.Lineage != sample.Lineage {
|
||||
t.Fatalf("lineage drift: got %+v want %+v", got.Lineage, sample.Lineage)
|
||||
}
|
||||
if got.AchievedLSN != sample.AchievedLSN || got.LastDataEpoch != sample.LastDataEpoch {
|
||||
t.Fatalf("AchievedLSN/LastDataEpoch drift: got %d/%d want %d/%d", got.AchievedLSN, got.LastDataEpoch, sample.AchievedLSN, sample.LastDataEpoch)
|
||||
if got.AchievedLSN != sample.AchievedLSN || got.LastDataEpoch != sample.LastDataEpoch || got.LastDataFirstLSN != sample.LastDataFirstLSN {
|
||||
t.Fatalf("AchievedLSN/LastDataEpoch/LastDataFirstLSN drift: got %+v want %+v", got, sample)
|
||||
}
|
||||
// A 40-byte response from a replica without the epoch table decodes with
|
||||
// LastDataEpoch 0 ("no table"); lengths between are malformed.
|
||||
if old, err := transport.DecodeBarrierResp(encoded[:40]); err != nil || old.LastDataEpoch != 0 || old.AchievedLSN != sample.AchievedLSN {
|
||||
t.Fatalf("40B response: %+v %v; want AchievedLSN kept and no table", old, err)
|
||||
}
|
||||
if _, err := transport.DecodeBarrierResp(encoded[:44]); err == nil {
|
||||
t.Fatal("DecodeBarrierResp on a 44B payload must reject")
|
||||
for _, n := range []int{44, 48, 52} {
|
||||
if _, err := transport.DecodeBarrierResp(encoded[:n]); err == nil {
|
||||
t.Fatalf("DecodeBarrierResp on a %dB payload must reject", n)
|
||||
}
|
||||
}
|
||||
|
||||
// And: a 39-byte payload must fail decode (would happen if
|
||||
|
||||
@@ -247,7 +247,7 @@ func (v *ReplicationVolume) reconcilePeer(ctx context.Context, peer *ReplicaPeer
|
||||
if err != nil {
|
||||
return false, false, fmt.Sprintf("barrier: %v", err)
|
||||
}
|
||||
if shared, ok := v.epochs.SharedEnd(ack.LastDataEpoch, ack.AchievedLSN); !ok {
|
||||
if shared, ok := v.epochs.SharedEnd(ack.LastDataEpoch, ack.LastDataFirstLSN, ack.AchievedLSN); !ok {
|
||||
return false, true, fmt.Sprintf("divergent (last data epoch %d, end %d; shared up to %d)", ack.LastDataEpoch, ack.AchievedLSN, shared)
|
||||
}
|
||||
if ack.AchievedLSN < frontier {
|
||||
@@ -584,7 +584,7 @@ func (v *ReplicationVolume) seedNewPeerLiveCursorsLocked(peers []*ReplicaPeer) {
|
||||
continue
|
||||
}
|
||||
if v.epochs != nil {
|
||||
if shared, ok := v.epochs.SharedEnd(ack.LastDataEpoch, ack.AchievedLSN); !ok {
|
||||
if shared, ok := v.epochs.SharedEnd(ack.LastDataEpoch, ack.LastDataFirstLSN, ack.AchievedLSN); !ok {
|
||||
markDiverged(peer, fmt.Sprintf("promotion seed barrier: divergent entries (last data epoch %d, end %d; shared up to %d)",
|
||||
ack.LastDataEpoch, ack.AchievedLSN, shared))
|
||||
log.Printf("replication: volume %s live cursor seed rejected peer=%s: divergent (epoch %d, end %d) shared to %d",
|
||||
|
||||
@@ -19,7 +19,8 @@ import (
|
||||
type BarrierAck struct {
|
||||
Lineage RecoveryLineage
|
||||
AchievedLSN uint64
|
||||
LastDataEpoch uint64 // the replica's last epoch-table row; 0 = no table (see BarrierResponse)
|
||||
LastDataEpoch uint64 // the replica's last data row's epoch; 0 = no table (see BarrierResponse)
|
||||
LastDataFirstLSN uint64 // that row's first LSN
|
||||
Success bool
|
||||
Reason string
|
||||
}
|
||||
@@ -41,9 +42,9 @@ var ErrBarrierLineageMismatch = errors.New("transport: barrier: response lineage
|
||||
// on cached primary-side assumptions (architect round-21 uniform
|
||||
// rule, INV-REPL-LINEAGE-BORNE-ON-BARRIER-ACK).
|
||||
//
|
||||
// Wire: [32B lineage][8B achievedLSN][8B lastDataEpoch] — 48 bytes. A
|
||||
// 40-byte response (a replica from before the epoch table) decodes with
|
||||
// LastDataEpoch 0, which the primary reads as "no table".
|
||||
// Wire: [32B lineage][8B achievedLSN][8B lastDataEpoch][8B lastDataFirstLSN]
|
||||
// — 56 bytes. A 40-byte response (a replica from before the epoch table)
|
||||
// decodes with LastDataEpoch 0, which the primary reads as "no table".
|
||||
// Lineage field order inside the 32B slab is strictly
|
||||
// SessionID, Epoch, EndpointVersion, frontierHint (matches
|
||||
// EncodeLineage). Any deviation MUST be rejected at decode.
|
||||
@@ -54,13 +55,16 @@ type BarrierResponse struct {
|
||||
// epoch of its entries at AchievedLSN); 0 = no table. An entry's
|
||||
// identity is (epoch, LSN): a length alone says nothing.
|
||||
LastDataEpoch uint64
|
||||
// LastDataFirstLSN is that row's first LSN: the primary requires it to
|
||||
// equal its own first LSN for the epoch (the receiver check).
|
||||
LastDataFirstLSN uint64
|
||||
}
|
||||
|
||||
// barrierRespSize is the exact byte length of a valid encoded
|
||||
// BarrierResponse. Short, over-long, or field-misordered payloads
|
||||
// are rejected by DecodeBarrierResp and MUST NOT contribute to
|
||||
// correctness decisions (round-21 rule).
|
||||
const barrierRespSize = 48
|
||||
const barrierRespSize = 56
|
||||
|
||||
// barrierRespV0Size is the response of a replica from before the epoch table.
|
||||
const barrierRespV0Size = 40
|
||||
@@ -68,12 +72,13 @@ const barrierRespV0Size = 40
|
||||
// EncodeBarrierResp serializes a barrier response.
|
||||
// Wire: [32B lineage (SessionID, Epoch, EndpointVersion, frontierHint)]
|
||||
//
|
||||
// [8B achievedLSN][8B lastDataEpoch]
|
||||
// [8B achievedLSN][8B lastDataEpoch][8B lastDataFirstLSN]
|
||||
func EncodeBarrierResp(r BarrierResponse) []byte {
|
||||
buf := make([]byte, barrierRespSize)
|
||||
copy(buf[0:32], EncodeLineage(r.Lineage))
|
||||
binary.BigEndian.PutUint64(buf[32:40], r.AchievedLSN)
|
||||
binary.BigEndian.PutUint64(buf[40:48], r.LastDataEpoch)
|
||||
binary.BigEndian.PutUint64(buf[48:56], r.LastDataFirstLSN)
|
||||
return buf
|
||||
}
|
||||
|
||||
@@ -111,6 +116,7 @@ func DecodeBarrierResp(buf []byte) (BarrierResponse, error) {
|
||||
}
|
||||
if len(buf) >= barrierRespSize {
|
||||
resp.LastDataEpoch = binary.BigEndian.Uint64(buf[40:48])
|
||||
resp.LastDataFirstLSN = binary.BigEndian.Uint64(buf[48:56])
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ func TestCatchUpKeepsTheHistorysEpochs(t *testing.T) {
|
||||
// The next promotion: epoch 3 from 11 on this node; the former primary is
|
||||
// byte-identical at epoch 1, end 10.
|
||||
_ = theirs.Note(3, 11)
|
||||
if _, shared := theirs.SharedEnd(1, 10); !shared {
|
||||
if _, shared := theirs.SharedEnd(1, 1, 10); !shared {
|
||||
t.Fatalf("an identical survivor (epoch 1, end 10) diverges from rows %v", theirs.Rows())
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package transport
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -51,7 +53,7 @@ func TestRebuildDoneReplacesTheEpochTableWithThePrimarysRows(t *testing.T) {
|
||||
t.Fatalf("replica rows %v; want %v", got, want)
|
||||
}
|
||||
}
|
||||
if _, ok := own.SharedEnd(theirs.LastDataEpochAt(end), end); !ok {
|
||||
if row := theirs.LastDataRowAt(end); func() bool { _, ok := own.SharedEnd(row.Epoch, row.FirstLSN, end); return !ok }() {
|
||||
t.Fatalf("the rebuilt replica (epoch %d, end %d) does not reconcile in sync", theirs.LastDataEpochAt(end), end)
|
||||
}
|
||||
}
|
||||
@@ -70,3 +72,50 @@ func TestEpochRowsWire(t *testing.T) {
|
||||
t.Fatal("unordered rows were accepted")
|
||||
}
|
||||
}
|
||||
|
||||
// A crash after the rebuilt store is synced and before the table is
|
||||
// replaced (here: the replace fails): no ack, so the rebuild is not done and
|
||||
// nothing counts the replica; the table it kept names its old history, which
|
||||
// reconciles as diverged: rebuild again, never a false in-sync.
|
||||
func TestRebuildDoneWithoutTheTableReplaceIsNotAcked(t *testing.T) {
|
||||
_, replica, listener := setupPrimaryReplica(t)
|
||||
theirs, _ := LoadEpochTable(filepath.Join(t.TempDir(), "v1.epoch-table"), "v1")
|
||||
_ = theirs.Replace([]EpochRow{{Epoch: 1, FirstLSN: 1}})
|
||||
listener.SetEpochTable(theirs)
|
||||
|
||||
primary := storage.NewBlockStore(64, 4096)
|
||||
writeTestBlocks(primary, 3)
|
||||
own, _ := LoadEpochTable("", "v1")
|
||||
_ = own.Replace([]EpochRow{{Epoch: 1, FirstLSN: 1}, {Epoch: 2, FirstLSN: 2}})
|
||||
|
||||
saved := floorFS
|
||||
t.Cleanup(func() { floorFS = saved })
|
||||
ops := osFloorOps
|
||||
ops.rename = func(string, string) error { return errors.New("injected: crash before the table replace") }
|
||||
floorFS = ops
|
||||
|
||||
exec := NewBlockExecutor(primary, listener.Addr())
|
||||
exec.SetEpochTable(own)
|
||||
closeCh := make(chan adapter.SessionCloseResult, 1)
|
||||
exec.SetOnSessionClose(func(r adapter.SessionCloseResult) { closeCh <- r })
|
||||
if err := exec.StartRebuild("r1", 2, 2, 1, 200); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
select {
|
||||
case r := <-closeCh:
|
||||
if r.Success {
|
||||
t.Fatalf("a rebuild whose table replace failed was acknowledged: %+v", r)
|
||||
}
|
||||
case <-time.After(3 * time.Second):
|
||||
t.Fatal("timeout waiting for the rebuild")
|
||||
}
|
||||
floorFS = saved
|
||||
if rows := theirs.Rows(); len(rows) != 1 || rows[0] != (EpochRow{Epoch: 1, FirstLSN: 1}) {
|
||||
t.Fatalf("replica rows %v; want the old rows kept", rows)
|
||||
}
|
||||
end, _ := replica.Sync()
|
||||
row := theirs.LastDataRowAt(end)
|
||||
if _, ok := own.SharedEnd(row.Epoch, row.FirstLSN, end); ok && end >= 2 {
|
||||
t.Fatalf("the stale table (epoch %d from %d, end %d) reconciles in sync; want diverged", row.Epoch, row.FirstLSN, end)
|
||||
}
|
||||
}
|
||||
@@ -227,18 +227,23 @@ func (t *EpochTable) LastEpoch() uint64 {
|
||||
// below end (the durable end). A row is made durable BEFORE the first entry
|
||||
// of its epoch, so a crash between the two leaves a row with no entry; it is
|
||||
// not counted here. 0 = no such row.
|
||||
func (t *EpochTable) LastDataEpochAt(end uint64) uint64 {
|
||||
func (t *EpochTable) LastDataEpochAt(end uint64) uint64 { return t.LastDataRowAt(end).Epoch }
|
||||
|
||||
// LastDataRowAt is the last row whose first LSN is at or below end, with that
|
||||
// first LSN; the zero row = none. The barrier reply carries both: two tables
|
||||
// can agree on an epoch number and still disagree on where it starts.
|
||||
func (t *EpochTable) LastDataRowAt(end uint64) EpochRow {
|
||||
if t == nil {
|
||||
return 0
|
||||
return EpochRow{}
|
||||
}
|
||||
t.mu.Lock()
|
||||
defer t.mu.Unlock()
|
||||
for i := len(t.rows) - 1; i >= 0; i-- {
|
||||
if t.rows[i].FirstLSN <= end {
|
||||
return t.rows[i].Epoch
|
||||
return t.rows[i]
|
||||
}
|
||||
}
|
||||
return 0
|
||||
return EpochRow{}
|
||||
}
|
||||
|
||||
// EncodeEpochRows is the wire form of rows: [4B count][count x (8B epoch,
|
||||
@@ -295,17 +300,20 @@ func (t *EpochTable) Rows() []EpochRow {
|
||||
return append([]EpochRow(nil), t.rows...)
|
||||
}
|
||||
|
||||
// SharedEnd answers a replica that reports its last data epoch and end LSN,
|
||||
// from this (the primary's) table: the highest LSN up to which the replica's
|
||||
// entries are this table's entries. shared is false when the replica holds
|
||||
// entries this table never had (a divergent tail or an unknown epoch): it
|
||||
// must not count until it is rebuilt.
|
||||
// SharedEnd answers a replica that reports its last data row (epoch and that
|
||||
// epoch's first LSN) and its end LSN, from this (the primary's) table: the
|
||||
// highest LSN up to which the replica's entries are this table's entries.
|
||||
// shared is false when the replica holds entries this table never had (a
|
||||
// divergent tail, an unknown epoch, or the same epoch starting elsewhere):
|
||||
// it must not count until it is rebuilt.
|
||||
// - the replica's epoch starts at another LSN here: diverged (an epoch
|
||||
// number alone is not a history);
|
||||
// - the replica's epoch is this table's last: in sync up to its end;
|
||||
// - else entries below the first LSN of the next epoch here are shared: an
|
||||
// end below it is a prefix, an end at or above it is divergent;
|
||||
// - no row here for the replica's epoch, or a replica with data but no
|
||||
// table (epoch 0): divergent. A replica with no data shares the empty prefix.
|
||||
func (t *EpochTable) SharedEnd(replicaEpoch, replicaEnd uint64) (end uint64, shared bool) {
|
||||
func (t *EpochTable) SharedEnd(replicaEpoch, replicaFirst, replicaEnd uint64) (end uint64, shared bool) {
|
||||
if replicaEnd == 0 {
|
||||
return 0, true
|
||||
}
|
||||
@@ -318,6 +326,12 @@ func (t *EpochTable) SharedEnd(replicaEpoch, replicaEnd uint64) (end uint64, sha
|
||||
if r.Epoch != replicaEpoch {
|
||||
continue
|
||||
}
|
||||
if r.FirstLSN != replicaFirst {
|
||||
if lo := min(r.FirstLSN, replicaFirst); lo > 1 {
|
||||
return lo - 1, false // the same epoch begins elsewhere: shared at most below either start
|
||||
}
|
||||
return 0, false
|
||||
}
|
||||
if i == len(t.rows)-1 {
|
||||
return replicaEnd, true
|
||||
}
|
||||
|
||||
@@ -93,22 +93,23 @@ func TestEpochTable_SharedEnd(t *testing.T) {
|
||||
_ = tb.Note(1, 1)
|
||||
_ = tb.Note(2, 50) // the new primary's epoch starts at 50
|
||||
for _, c := range []struct {
|
||||
name string
|
||||
epoch, end uint64
|
||||
wantEnd uint64
|
||||
wantShared bool
|
||||
name string
|
||||
epoch, first, end uint64
|
||||
wantEnd uint64
|
||||
wantShared bool
|
||||
}{
|
||||
{"no data", 0, 0, 0, true},
|
||||
{"data but no table", 0, 40, 0, false},
|
||||
{"current epoch", 2, 70, 70, true},
|
||||
{"old epoch, prefix", 1, 49, 49, true},
|
||||
{"old epoch, equal length, divergent", 1, 50, 49, false},
|
||||
{"old epoch, above, divergent", 1, 60, 49, false},
|
||||
{"unknown epoch", 3, 10, 0, false},
|
||||
{"no data", 0, 0, 0, 0, true},
|
||||
{"data but no table", 0, 0, 40, 0, false},
|
||||
{"current epoch", 2, 50, 70, 70, true},
|
||||
{"old epoch, prefix", 1, 1, 49, 49, true},
|
||||
{"old epoch, equal length, divergent", 1, 1, 50, 49, false},
|
||||
{"old epoch, above, divergent", 1, 1, 60, 49, false},
|
||||
{"unknown epoch", 3, 5, 10, 0, false},
|
||||
{"current epoch starting elsewhere", 2, 52, 70, 49, false},
|
||||
} {
|
||||
end, shared := tb.SharedEnd(c.epoch, c.end)
|
||||
end, shared := tb.SharedEnd(c.epoch, c.first, c.end)
|
||||
if end != c.wantEnd || shared != c.wantShared {
|
||||
t.Errorf("%s: SharedEnd(%d, %d) = (%d, %t); want (%d, %t)", c.name, c.epoch, c.end, end, shared, c.wantEnd, c.wantShared)
|
||||
t.Errorf("%s: SharedEnd(%d, %d, %d) = (%d, %t); want (%d, %t)", c.name, c.epoch, c.first, c.end, end, shared, c.wantEnd, c.wantShared)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,10 +29,10 @@ func TestEpochTable_TrimAboveTheRecoveredEndKeepsTheNewWritesInTheirEpoch(t *tes
|
||||
if err := again.Note(2, 6); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, shared := again.SharedEnd(1, 8); shared {
|
||||
if _, shared := again.SharedEnd(1, 1, 8); shared {
|
||||
t.Fatalf("an epoch-1 tail ending at 8 reconciles as shared with rows %v; want diverged (6..8 are epoch 2 here)", again.Rows())
|
||||
}
|
||||
if _, shared := again.SharedEnd(1, 5); !shared {
|
||||
if _, shared := again.SharedEnd(1, 1, 5); !shared {
|
||||
t.Fatalf("the shared epoch-1 prefix to 5 is not shared with rows %v", again.Rows())
|
||||
}
|
||||
reloaded, _ := LoadEpochTable(path, "v1")
|
||||
|
||||
@@ -573,7 +573,8 @@ func (e *BlockExecutor) Barrier(replicaID string, lineage RecoveryLineage, front
|
||||
return BarrierAck{
|
||||
Lineage: resp.Lineage,
|
||||
AchievedLSN: resp.AchievedLSN,
|
||||
LastDataEpoch: resp.LastDataEpoch,
|
||||
LastDataEpoch: resp.LastDataEpoch,
|
||||
LastDataFirstLSN: resp.LastDataFirstLSN,
|
||||
Success: true,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -577,7 +577,8 @@ func (r *ReplicaListener) handleConn(conn net.Conn) {
|
||||
resp := EncodeBarrierResp(BarrierResponse{
|
||||
Lineage: lineage,
|
||||
AchievedLSN: frontier,
|
||||
LastDataEpoch: r.epochs.LastDataEpochAt(frontier),
|
||||
LastDataEpoch: r.epochs.LastDataRowAt(frontier).Epoch,
|
||||
LastDataFirstLSN: r.epochs.LastDataRowAt(frontier).FirstLSN,
|
||||
})
|
||||
replyType, reply = MsgBarrierResp, resp
|
||||
return true
|
||||
@@ -627,7 +628,8 @@ func (r *ReplicaListener) handleConn(conn net.Conn) {
|
||||
resp := EncodeBarrierResp(BarrierResponse{
|
||||
Lineage: lineage,
|
||||
AchievedLSN: frontier,
|
||||
LastDataEpoch: r.epochs.LastDataEpochAt(frontier),
|
||||
LastDataEpoch: r.epochs.LastDataRowAt(frontier).Epoch,
|
||||
LastDataFirstLSN: r.epochs.LastDataRowAt(frontier).FirstLSN,
|
||||
})
|
||||
replyType, reply = MsgBarrierResp, resp
|
||||
|
||||
|
||||
@@ -782,8 +782,8 @@ Notes:
|
||||
| `INV-REPL-PEER-TRANSITIONS-001` | `ReplicaPeer.SetState` and `ReplicaPeer.Invalidate` apply only the transitions in the peer table; `NeedsRebuild` has no successor through either. | M3 peer state | `core/replication/peer.go` `ReplicaPeer.SetState`, `ReplicaPeer.Invalidate`, `replicaStateTransitionAllowed` | `TestReplicaStateTransition_AllowedSet`, `TestReplicaStateTransition_RejectedSet`, `TestReplicaStateTransition_NeedsRebuildIsTerminalInT4c` (`core/replication/peer_state_machine_test.go`); `TestReplicaPeer_InvalidatePreservesNeedsRebuildTerminalState` (`core/replication/invalidate_terminal_regression_test.go`); `TestReplicaPeer_InvalidateNonTerminalStatesBecomeDegraded`, `TestReplicaPeer_InvalidateOnNeedsRebuildStillLogsReason` (`core/replication/invalidate_transition_test.go`) | — | ACTIVE |
|
||||
| `INV-REPL-DURABILITY-MODE-001` | Under `sync_all` a replicated `Sync` fails if any replica barrier fails; under `sync_quorum` it fails unless a majority of nodes, the primary included, are durable. | M3 barrier evaluation | `core/replication/durability.go` `EvaluateBarrierAcks` | `TestDurabilityCoordinator_Quorum_RF3_OneReplicaFailed`, `TestDurabilityCoordinator_Quorum_RF3_BothReplicasFailed`, `TestDurabilityCoordinator_SyncAll_AnyFailure_Fails` (`core/replication/durability_test.go`) | — | ACTIVE |
|
||||
| `INV-REPL-PROMOTION-READY-001` | A replica reports `promotion_ready` only if it is a member, reachable, caught up, fenced at the current epoch, and has delivered its post-rebuild durable acknowledgement. An active recovery session always refuses readiness, even if delayed bounds select DecisionNone. | M3 Supporting → promotion candidate | `core/engine/promotion_ready.go` `BuildPromotionReadyFact` | `TestBuildPromotionReadyFact_RefusesPendingFence`, `TestBuildPromotionReadyFact_RefusesPostCloseAckGap`, `TestBuildPromotionReadyFact_RefusesNotCaughtUp` (`core/engine/promotion_ready_test.go`), `TestPromotionReadyRefusesDelayedProbeDuringNewRecovery` | `WALReplica` `I3`; `ReplicationFailover` `AckedSurvive`; `ReplicaReviewGuards` ReadyRequiresIdle | ACTIVE |
|
||||
| `INV-REPL-DIVERGENT-TAIL-001` | A peer is counted only after a reconciliation in this session finds its (last data epoch, end) in sync with the primary's epoch table; an equal length of another epoch, a tail above the frontier or data without a table is diverged: NeedsRebuild, never healed by length. | M3 Healthy → Degraded → NeedsRebuild (seed, heal) | `core/replication/volume.go` `seedNewPeerLiveCursorsLocked`, `reconcilePeer`, `markDiverged`; `core/replication/peer.go` `HealIfInSync`; `core/replication/peer_work_queue.go` (barrier); `core/host/volume/peer_command_executor.go` `PublishHealthy`; `core/engine/apply.go` `decide` | `TestPromotionSeed_EqualLengthDivergentEpochIsRebuilt`, `TestPromotionSeed_EpochTableControls` (`core/replication/divergent_epoch_seed_test.go`); `TestReplicationVolume_UpdateReplicaSet_DegradesPeerAboveLocalFrontier` (`core/replication/divergent_tail_seed_test.go`); `TestPublishHealthyNeverHealsAnEqualLengthDivergentPeer` (`core/host/volume/peer_heal_reconcile_test.go`); `TestDivergentTailBeforeTheEpochIsAcceptedIsRebuilt` (`core/engine/divergent_tail_test.go`); `TestPeerAdapterRegistry_DivergentTailAboveTheFrontierAtAddIsRebuilt` (`core/host/volume/peer_adapter_divergent_tail_test.go`) | `Promo` rule 7 (G4), row `mut_g4_no_truncate` | ACTIVE |
|
||||
| `INV-REPL-EPOCH-TABLE-001` | Each volume keeps a durable epoch -> first LSN table; a row is durable before any entry of its epoch (replica: before the apply; primary: at role adoption, at the next LSN); a rebuild takes the primary's rows cut at its end; a load drops rows above the recovered next LSN; at most 512 rows. | M3 replica apply, Primary adoption, rebuild done | `core/transport/epoch_table.go` `EpochTable.Note`, `Replace`, `SharedEnd`, `LastDataEpochAt`; `core/transport/replica.go` (ship entry, rebuild done, barrier reply); `core/transport/rebuild_sender.go`; `cmd/blockvolume/replication_ingress.go` `notePrimaryEpoch` | `TestEpochTable_NoteIsDurableAndOrdered`, `TestEpochTable_InterruptEveryPersistStep`, `TestEpochTable_LastDataEpochAtTheDurableEnd`, `TestEpochTable_SharedEnd` (`core/transport/epoch_table_test.go`); `TestRebuildDoneReplacesTheEpochTableWithThePrimarysRows`, `TestEpochRowsWire` (`core/transport/epoch_rebuild_test.go`); `TestCatchUpKeepsTheHistorysEpochs` (`core/transport/epoch_catchup_test.go`); `TestEpochTable_TrimAboveTheRecoveredEndKeepsTheNewWritesInTheirEpoch`, `TestEpochTable_BoundedSoItAlwaysReloads` (`core/transport/epoch_table_trim_test.go`); `TestEpochTableHasExactlyItsListedWriters`, `TestEpochTableWriterCensusFindsAFourth` (`core/transport/epoch_table_writers_guard_test.go`) | `Promo` Truncate (common prefix by (epoch, LSN)) | ACTIVE |
|
||||
| `INV-REPL-DIVERGENT-TAIL-001` | A peer is counted only after a reconciliation in this session finds its (last data epoch, end) in sync with the primary's epoch table; an equal length of another epoch, a tail above the frontier or data without a table is diverged: NeedsRebuild, never healed by length. | M3 Healthy → Degraded → NeedsRebuild (seed, heal) | `core/replication/volume.go` `seedNewPeerLiveCursorsLocked`, `reconcilePeer`, `markDiverged`; `core/replication/peer.go` `HealIfInSync`; `core/replication/peer_work_queue.go` (barrier); `core/host/volume/peer_command_executor.go` `PublishHealthy`; `core/engine/apply.go` `decide` | `TestPromotionSeed_EqualLengthDivergentEpochIsRebuilt`, `TestPromotionSeed_SameEpochStartingElsewhereIsRebuilt`, `TestPromotionSeed_EpochTableControls` (`core/replication/divergent_epoch_seed_test.go`); `TestReplicationVolume_UpdateReplicaSet_DegradesPeerAboveLocalFrontier` (`core/replication/divergent_tail_seed_test.go`); `TestPublishHealthyNeverHealsAnEqualLengthDivergentPeer` (`core/host/volume/peer_heal_reconcile_test.go`); `TestDivergentTailBeforeTheEpochIsAcceptedIsRebuilt` (`core/engine/divergent_tail_test.go`); `TestPeerAdapterRegistry_DivergentTailAboveTheFrontierAtAddIsRebuilt` (`core/host/volume/peer_adapter_divergent_tail_test.go`) | `Promo` rule 7 (G4), row `mut_g4_no_truncate` | ACTIVE |
|
||||
| `INV-REPL-EPOCH-TABLE-001` | Each volume keeps a durable epoch -> first LSN table; a row is durable before any entry of its epoch (replica: before the apply; primary: at role adoption, at the next LSN); a rebuild takes the primary's rows cut at its end; a load drops rows above the recovered next LSN; at most 512 rows. | M3 replica apply, Primary adoption, rebuild done | `core/transport/epoch_table.go` `EpochTable.Note`, `Replace`, `SharedEnd`, `LastDataEpochAt`; `core/transport/replica.go` (ship entry, rebuild done, barrier reply); `core/transport/rebuild_sender.go`; `cmd/blockvolume/replication_ingress.go` `notePrimaryEpoch` | `TestEpochTable_NoteIsDurableAndOrdered`, `TestEpochTable_InterruptEveryPersistStep`, `TestEpochTable_LastDataEpochAtTheDurableEnd`, `TestEpochTable_SharedEnd` (`core/transport/epoch_table_test.go`); `TestRebuildDoneReplacesTheEpochTableWithThePrimarysRows`, `TestRebuildDoneWithoutTheTableReplaceIsNotAcked`, `TestEpochRowsWire` (`core/transport/epoch_rebuild_test.go`); `TestCatchUpKeepsTheHistorysEpochs` (`core/transport/epoch_catchup_test.go`); `TestEpochTable_TrimAboveTheRecoveredEndKeepsTheNewWritesInTheirEpoch`, `TestEpochTable_BoundedSoItAlwaysReloads` (`core/transport/epoch_table_trim_test.go`); `TestEpochTableHasExactlyItsListedWriters`, `TestEpochTableWriterCensusFindsAFourth` (`core/transport/epoch_table_writers_guard_test.go`) | `Promo` Truncate (common prefix by (epoch, LSN)) | ACTIVE |
|
||||
| `INV-ROLE-STALE-REPLAY-001` | A role call below the host's current desired epoch is refused and cannot clear a newer role-admission failure. | M3 role admission | `core/host/volume/host.go` `fenceSelfWithPeers`, `latchRoleAdmission` | `TestG1_StaleReplayDoesNotClearANewerAdmissionFailure`, `TestG1_StaleSupportingReplayDoesNotClearTheLatch` (`core/host/volume/g1_admission_latch_test.go`) | — | ACTIVE |
|
||||
| `INV-ROLE-READINESS-BLOCK-001` | While local recovery blocks readiness, `applyFact` admits neither a primary nor a supporting role, and replays the stored fact once readiness clears. | M3 Unassigned → Primary \| Supporting (guard) | `core/host/volume/host.go` `applyFact`, `replayLocalReadinessFactIfReady` | `TestHost_ApplyFact_Self_LocalReadinessBlocked_SkipsReplicationAndAdapter`, `TestHost_ApplyFact_SupportingReplica_LocalReadinessBlocked_SkipsAdapter`, `TestHost_ApplyFact_Self_ReplaysAfterLocalReadinessClearsWithReplicationFirst` (`core/host/volume/apply_fact_test.go`) | — | ACTIVE |
|
||||
| `INV-ROLE-SUPERSEDED-001` | A fact naming another replica as primary, with this replica not among its peers, never reaches this host's adapter or replication, and is recorded as the other line. | M3 Primary \| Supporting → Excluded | `core/host/volume/host.go` `applyFact`, `recordOtherLine` | `TestHost_ApplyFact_Supersede_NeverCallsAdapterOrReplication` (`core/host/volume/apply_fact_test.go`); `TestHost_BuildReport_SupersededReplicaNotReadyForPrimary` (`core/host/volume/frontend_targets_test.go`) | — | ACTIVE |
|
||||
|
||||
Reference in new issue
Block a user