mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 02:27:26 +01:00
storage: the presence file is evidence only before the marker
A store marked at this epoch is never seeded from the presence file: a complete record only has the file removed, an incomplete one gets its pages again from the store's bitmap through the boundary's same-epoch retry, with a seed that refuses. A store marked at another epoch is refused, typed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
013b6222fe
commit
930f74ea95
2 files changed
+36
-10
No files matched your search
@@ -85,6 +85,14 @@ func readLegacyPresence(path string) (legacyPresence, error) {
|
||||
|
||||
func chunkPresencePath(storePath string) string { return storePath + ".chunkpresence" }
|
||||
|
||||
// ErrChunkRecordOtherEpoch refuses an upgrade of a store already marked at
|
||||
// another local-work epoch: that store belongs to the attach after a move.
|
||||
var ErrChunkRecordOtherEpoch = errors.New("storage: chunk record: store marked at another local-work epoch")
|
||||
|
||||
// errPresenceAfterMarker: the presence file is never a seed once the store is
|
||||
// marked; reaching the seed then is a defect.
|
||||
var errPresenceAfterMarker = errors.New("storage: chunk record: the presence file is not evidence after the marker")
|
||||
|
||||
// upgradeChunkRecord is the one-way upgrade of a v1.0.x volume's per-chunk
|
||||
// state, at open: after Recover and Sync, with extent draining held, before
|
||||
// the chunk layer attaches. It reads no chunk data. In order:
|
||||
@@ -101,8 +109,16 @@ func chunkPresencePath(storePath string) string { return storePath + ".chunkpres
|
||||
// store, G its synced position);
|
||||
// 5. the presence file is removed.
|
||||
//
|
||||
// Each step can be repeated. A store whose record is already complete only
|
||||
// has its presence file removed.
|
||||
// Each step can be repeated.
|
||||
//
|
||||
// THE PRESENCE FILE IS EVIDENCE ONLY BEFORE THE MARKER. Once the store is
|
||||
// marked, its bitmap is the durable fact and a missing presence file would
|
||||
// read as "nothing absent": absent chunks would serve local bytes never
|
||||
// fetched. So: a store marked at this epoch is never seeded from the file; a
|
||||
// complete record only has the file removed, an incomplete one gets its pages
|
||||
// again from the store's bitmap (the same-epoch retry of the store's boundary,
|
||||
// which takes no seed). A store marked at another epoch is refused. Only an
|
||||
// unmarked store is seeded from the presence file.
|
||||
func upgradeChunkRecord(ctx context.Context, s *WALStore, epoch uint64) error {
|
||||
cb := s.ChunkBlocks()
|
||||
if cb == 0 {
|
||||
@@ -110,15 +126,29 @@ func upgradeChunkRecord(ctx context.Context, s *WALStore, epoch uint64) error {
|
||||
}
|
||||
chunks := (uint64(s.NumBlocks()) + cb - 1) / cb
|
||||
dir, presence := chunkRecordDir(s.path), chunkPresencePath(s.path)
|
||||
if marked, e := s.ChunkStateMarker(); marked && e == epoch {
|
||||
prepare := func(r ChunkCoverageReader) error {
|
||||
pos, _, _ := s.Boundaries()
|
||||
return writeChunkRecordPagesFrom(dir, chunks, pos, r)
|
||||
}
|
||||
if marked, e := s.ChunkStateMarker(); marked {
|
||||
if e != epoch {
|
||||
return fmt.Errorf("%w: marked %d, upgrade asked at %d", ErrChunkRecordOtherEpoch, e, epoch)
|
||||
}
|
||||
pos, _, _ := s.Boundaries()
|
||||
got, err := loadChunkRecord(dir, chunks, marked, e, pos)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if got.Complete {
|
||||
return removeLegacyPresence(presence)
|
||||
if !got.Complete {
|
||||
noSeed := func(uint64, uint64) (ChunkCoverageSeed, error) { return ChunkCoverageSeed{}, errPresenceAfterMarker }
|
||||
if err := s.InitializeChunkCoverage(ctx, epoch, noSeed, prepare); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := completeChunkRecord(s, dir, epoch, chunks); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return removeLegacyPresence(presence)
|
||||
}
|
||||
legacy, err := readLegacyPresence(presence)
|
||||
if err != nil {
|
||||
@@ -144,10 +174,6 @@ func upgradeChunkRecord(ctx context.Context, s *WALStore, epoch uint64) error {
|
||||
}
|
||||
return ChunkCoverageSeed{Blocks: local}, nil
|
||||
}
|
||||
prepare := func(r ChunkCoverageReader) error {
|
||||
pos, _, _ := s.Boundaries()
|
||||
return writeChunkRecordPagesFrom(dir, chunks, pos, r)
|
||||
}
|
||||
if err := s.InitializeChunkCoverage(ctx, epoch, seed, prepare); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -616,7 +616,7 @@ The "Machine / transition" column refers to Part A. Notes under a table record w
|
||||
| `INV-WAL-V3-DESCRIPTOR-001` | A v3 descriptor slot is used only if it is valid: a matching CRC32C (Castagnoli), every reserved byte zero, an accepted impl, a nonzero slotGen at most 2^64-2, a nonzero nonce, and geometry consistent under checked arithmetic. | M1 Opened (v3 descriptor selection) | `core/storage/superblock_v3.go` `decodeSlotV3`, `descriptorV3.validate`, `checkedAddV3` | `TestSlotV3VectorsDecodeAsExpected`, `TestSlotV3CounterExhaustion` (`core/storage/superblock_v3_test.go`) | — | STUB |
|
||||
| `INV-WAL-V3-DESCRIPTOR-BASE-001` | A valid v3 descriptor slot has CheckpointLSN ≤ mapCoveredCheckpoint ≤ W, and BASE fields that follow the rules of its BASE state. | M1 Opened (v3 descriptor selection) | `core/storage/superblock_v3.go` `descriptorV3.validate` | `TestSlotV3VectorsDecodeAsExpected`, `TestSlotV3InstalledMayHaveCursorBelowTail` (`core/storage/superblock_v3_test.go`) | — | STUB |
|
||||
| `INV-CHUNK-RECORD-PAGES-CURRENT-001` | An unfinished chunk record is used, and its header written, only when every page passes its check and is valid through exactly the store's synced position after recovery (behind: missed writes; ahead: not durable); an unmarked store discards it; the header follows the two-slot fence. | M1 Opened (chunk record load, v1.1 upgrade) | `core/storage/chunk_record.go` `loadChunkRecord`, `completeChunkRecord` | `TestUnfinishedRecordPagesBehindTheStoreAreNotTrusted`, `TestUnfinishedRecordAfterAnOldCheckpointIsDiscarded`, `TestStalePagesAreNeverCompleted`, `TestUnfinishedPagesAheadOfTheStoreAreNotTrusted`, `TestCompleteRecordAheadOfTheStoreIsNotTrusted`, `TestCompleteRecordPagePositions`, `TestRecordHeaderWaitsForTheFence`, `TestRecordHeaderIsNotWrittenAheadOfTheSyncedStore`, `TestDamagedPage` (`core/storage/chunk_record_test.go`) | SlotFence `PagesCurrent`, `FenceHolds`; pages carry chunk-kernel/2 states (the per-chunk state models are not in this repository) | STUB |
|
||||
| `INV-CHUNK-RECORD-UPGRADE-001` | The v1.0.x upgrade at open classifies each chunk by the kernel from its seeded coverage (present: all; absent: the file's local blocks plus unapplied log blocks), writes pages before the store's fence, the header after it, and removes the presence file last; each step repeats. | M1 Opened (v1.1 upgrade at open) | `core/storage/chunk_record_upgrade.go` `upgradeChunkRecord`, `writeChunkRecordPagesFrom` | `TestUpgradeChunkRecordFromLegacyPresence`, `TestUpgradeChunkRecordCrashBeforeTheFence`, `TestUpgradeChunkRecordCrashAfterTheHeader` (`core/storage/chunk_record_upgrade_test.go`) | UpgradeWide3 (pages, field, header, presence removed); chunk-kernel/2 `Rebuilt` (the per-chunk state models are not in this repository) | STUB |
|
||||
| `INV-CHUNK-RECORD-UPGRADE-001` | The v1.0.x upgrade seeds the bitmap from the presence file only on an unmarked store; marked at this epoch it rebuilds pages from the store's bitmap, at another epoch it refuses; pages precede the fence, the header follows it, the presence file goes last. | M1 Opened (v1.1 upgrade at open) | `core/storage/chunk_record_upgrade.go` `upgradeChunkRecord`, `writeChunkRecordPagesFrom` | `TestUpgradeChunkRecordFromLegacyPresence`, `TestUpgradeChunkRecordCrashBeforeTheFence`, `TestUpgradeChunkRecordCrashAfterTheHeader`, `TestUpgradeChunkRecordAfterTheMarkerIgnoresThePresenceFile`, `TestUpgradeChunkRecordAtAnotherEpochIsRefused` (`core/storage/chunk_record_upgrade_test.go`) | UpgradeWide3 (pages, field, header, presence removed); ChunkUpgrade row 118; chunk-kernel/2 `Rebuilt` (the per-chunk state models are not in this repository) | STUB |
|
||||
| `INV-CHUNK-UPGRADE-PASS-CURSOR-001` | Upgrade pass: rewinds only at open, before Run; a failed rewind latches it until reopen; the persisted cursor is only ever min(earliest unpublished rewind, last written-through position); a restart resumes there; while it runs, a request needing every hash answers in_progress. | M1 Opened (v1.1 upgrade compare pass) | `core/storage/chunk_upgrade_pass.go` `upgradePass.Run`, `advance`, `Rewind`, `Admit` | `TestUpgradePassCursorFollowsThePagesBehindIt`, `TestUpgradePassRestartContinuesAtTheCursor`, `TestUpgradePassRefusesWithProgress`, `TestUpgradePassRewindAtOpenAfterARebuiltPage`, `TestUpgradePassPauseAndHurry`, `TestUpgradePassFailedRewindLatchesUntilReopen`, `TestUpgradePassRewindOnlyBeforeRun`, `TestUpgradePassKeepsItsCountAcrossRuns`, `TestUpgradePassCursorRuleUnderInterleavings` (`core/storage/chunk_upgrade_pass_test.go`) | UpgradePass `BehindCursorKnown`, `NoWorkTwice`; UpgradeWide3 rows 119 to 124, rewinds at restart only (the per-chunk state models are not in this repository) | STUB |
|
||||
| `INV-CHUNK-RECORD-RUNTIME-001` | While serving: state only via the kernel, a known hash only with its evidence; a page dirties only when a state or hash changes, is written by its own count or age, an evict's at once, in snapshot order; header G = min(applied, dirty pages' dirty-from). | M3 Serving (chunk record runtime) | `core/storage/chunk_record_runtime.go` `chunkRecordRuntime.Apply`, `Due`, `WriteDue`, `WriteThrough`, `Flush` | `TestRecordRuntimeAppliesTheKernel`, `TestRecordRuntimeEvictWritesThePageFirst`, `TestRecordRuntimeSchedulePerPage`, `TestRecordRuntimeFlushIsLoadedBack`, `TestRecordRuntimeWriteThrough`, `TestRecordRuntimeAnUnchangedStateWritesNothing`, `TestRecordRuntimeHeaderMovesUnderWrites`, `TestRecordRuntimeEvictDuringAFlushLandsLast`, `TestRecordRuntimePageWritesFollowChangesNotSize`, `TestRecordRuntimePageWritersPublishInOrder`, `TestRecordRuntimeHashEvidence`, `TestRecordRuntimeCopiesItsInputs`, `TestRecordRuntimeAPageChangedAtOpenHoldsG` (`core/storage/chunk_record_runtime_test.go`) | chunk-kernel/2; ChunkPages rule 1 (pages before the header) and rule 3 (an evict writes its page first) (the per-chunk state models are not in this repository) | STUB |
|
||||
| `INV-CHUNK-RECORD-PAYLOAD-001` | Persisting and loading a chunk record preserves every entry's state and hash, including entries on either side of a segment boundary. | M1 chunk record codec (caller not wired) | `core/storage/chunk_record.go` `encodeChunkRecordPage`, `decodeChunkRecordPage` | `TestRecordEntryPayloadRoundTripsAcrossSegments` (`core/storage/chunk_record_test.go`; state-zero and one-entry hash-drop controls) | Encoding fidelity; no state transition change | STUB |
|
||||
|
||||
Reference in new issue
Block a user