mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 10:07:28 +01:00
test: cover cut abort status and named snapshot failure
This commit is contained in:
1 parent
d3ad5aa87c
commit
f87f513bdf
8 files changed
+37
-7
No files matched your search
@@ -411,9 +411,12 @@ func TestWALStoreChunk_InitialWriteAnonymousMemory(t *testing.T) {
|
||||
anon, _ = memoryAnonBytes()
|
||||
t.Logf("after QD32 anon=%d MiB", anon>>20)
|
||||
if os.Getenv("SWBLOCK_MEMORY_CUT") != "0" {
|
||||
if _, err = p.CaptureVolume(ctx, "v1"); err != nil {
|
||||
t.Fatal(err)
|
||||
cutStart := time.Now()
|
||||
cut, cutErr := p.CutVolume(ctx, "v1", 0)
|
||||
if cutErr != nil {
|
||||
t.Fatal(cutErr)
|
||||
}
|
||||
t.Logf("first_cut_bytes=%d wall=%s stageRounds=%d candidates=%d", cfg.NumBlocks*4096, time.Since(cutStart), cut.Stats.StageRounds, cut.Stats.CandidateChunks)
|
||||
if os.Getenv("SWBLOCK_MEMORY_FULL") != "" {
|
||||
head, e := r.GetHead(ctx)
|
||||
if e != nil {
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package volume
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/seaweedfs/seaweed-block/core/frontend/chunkstore"
|
||||
"github.com/seaweedfs/seaweed-block/core/storage"
|
||||
"net/http"
|
||||
"testing"
|
||||
@@ -18,3 +20,16 @@ func TestChunkBudgetAdmissionRefusalIsRetryable(t *testing.T) {
|
||||
t.Fatalf("fenced: %d retry=%v", status, retry)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNamedSnapshotWindowAbortNeverSubstitutesPoint(t *testing.T) {
|
||||
fp, ctl := adapterFixture(t)
|
||||
fp.cutErr = storage.ErrCutCOWAborted
|
||||
info, err := ctl.Snapshot(context.Background(), "v1", ChunkSnapshotRequest{Name: "exact-point", RequestID: "attempt-1"})
|
||||
if !errors.Is(err, storage.ErrCutCOWAborted) || fp.cuts != 1 || info.HeadGen != 0 {
|
||||
t.Fatalf("snapshot=%+v cuts=%d err=%v", info, fp.cuts, err)
|
||||
}
|
||||
entries, _, listErr := ctl.ListSnapshots(context.Background(), "v1", chunkstore.ListOptions{})
|
||||
if listErr != nil || len(entries) != 0 {
|
||||
t.Fatalf("aborted named request published: %+v %v", entries, listErr)
|
||||
}
|
||||
}
|
||||
@@ -121,6 +121,9 @@ func TestCutBudgetRevocationJoinsBeforeRelease(t *testing.T) {
|
||||
if err := <-errs; !errors.Is(err, errTestCutBudget) {
|
||||
t.Fatalf("revoked capture: %v", err)
|
||||
}
|
||||
if l.Stats().CutsAborted["budget_revoked"] != 1 {
|
||||
t.Fatal("missing budget revoke status")
|
||||
}
|
||||
if f.stats().head.Gen != before {
|
||||
t.Fatal("revoked point published")
|
||||
}
|
||||
|
||||
@@ -351,7 +351,7 @@ func (w *cutCOWWindow) save(e *cutCOWEntry, data []byte, missing []uint64) error
|
||||
// The side file is sparse but its saved chunks are real bytes on the
|
||||
// volume's filesystem: abort the cut (retried) instead of filling it.
|
||||
w.mu.Unlock()
|
||||
return fmt.Errorf("%w: %w: limit %d bytes", errCutCOWAborted, errCutCOWCapacity, w.spillLimit)
|
||||
return fmt.Errorf("%w: %w: COW spill would exceed its cap of %d bytes", errCutCOWAborted, errCutCOWCapacity, w.spillLimit)
|
||||
} else {
|
||||
w.spillBytes += w.chunkBytes
|
||||
}
|
||||
|
||||
@@ -66,6 +66,9 @@ func TestCutCOWV3_SaverCapacityAbortsWithoutParkingGuest(t *testing.T) {
|
||||
if err := <-errs; !errors.Is(err, errCutCOWAborted) {
|
||||
t.Fatalf("cut: %v", err)
|
||||
}
|
||||
if l.Stats().CutsAborted["saver_capacity"] != 1 {
|
||||
t.Fatal("missing saver abort status")
|
||||
}
|
||||
if f.stats().head.Gen != before {
|
||||
t.Fatal("capacity-refused cut published")
|
||||
}
|
||||
@@ -149,6 +152,9 @@ func TestCutCOWV3_SpillCapAbortsTheCut(t *testing.T) {
|
||||
if err := <-cutErr; !errors.Is(err, errCutCOWAborted) || !strings.Contains(err.Error(), "spill would exceed its cap") {
|
||||
t.Fatalf("cut past the spill cap: %v, want the cap abort", err)
|
||||
}
|
||||
if l.Stats().CutsAborted["cow_capacity"] != 1 {
|
||||
t.Fatal("missing COW cap status")
|
||||
}
|
||||
if _, err := l.Cut(context.Background()); err != nil {
|
||||
t.Fatal("retried cut:", err)
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestCutPayloadIntentCountIndependentOfCandidates(t *testing.T) {
|
||||
for _, n := range []int{4, 12} {
|
||||
for _, n := range []int{4, 8} {
|
||||
_, f, l, _ := precopyLayer(t, 0, n)
|
||||
l.cfg.UploadConcurrency = 1
|
||||
before := len(f.putIntents)
|
||||
@@ -125,7 +125,7 @@ func TestV3ReadLargeBatchScratchIsBlockBounded(t *testing.T) {
|
||||
}
|
||||
// Corruption outside the requested block must still fail the whole-record CRC.
|
||||
at := int64(s.sb.WALOffset + off + walEntryPrefixSizeV3 + 255*4096)
|
||||
if _, err = s.fd.WriteAt([]byte{0xff}, at); err != nil {
|
||||
if _, err = s.fd.WriteAt([]byte{0x17}, at); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
_, ioErr, verr = s.readRecordV3(3, off, dataOff, lsn)
|
||||
|
||||
@@ -176,6 +176,9 @@ func TestChunkCutUploadDeadlineBoundRetainsDirt(t *testing.T) {
|
||||
if _, err := layer.Cut(ctx); err == nil {
|
||||
t.Fatal("persistent upload outage published")
|
||||
}
|
||||
if layer.Stats().CutsAborted["upload"] != 1 {
|
||||
t.Fatal("missing upload abort status")
|
||||
}
|
||||
r.mu.Lock()
|
||||
if len(r.calls) != 1 {
|
||||
t.Fatalf("retry changed object keys: %v", r.calls)
|
||||
|
||||
@@ -453,8 +453,8 @@ Notes:
|
||||
| `INV-CUT-HOOK-BEFORE-APPEND` | The COW hook owns/saves the at-H image before a read-visible WAL mutation, under shared capture admission. | M1 Write / M5 Save | `walstore.go` `Write`, `WriteBatch`; `chunk_cut_cow.go` `beforeChunkMutation` | `TestCutCOWV3_MutationCompletesWhileEarlierChunkCopyIsHeld`, `TestCutCOWV3_OverlappingRealBatchesPreserveCut` | CutCOW2 SaveStart before Write | ACTIVE |
|
||||
| `INV-CUT-FILL-FROM-BASE` | Lazily absent blocks are filled from this cut's fixed base HEAD, never a newer remote HEAD. Remote fetch runs after releasing local ownership. | M5 Copy / lazy fill | `chunk_cut_cow.go` `readCOWChunk`, `fillMissing` | `TestCutCOWV3_LazySaverSpillImageIsExact`, `TestCutCOWV3_SaverUsesValidatedWALBatchAndLazyHEAD` | Remote fill not modelled; native byte-image controls | ACTIVE |
|
||||
| `PROGRESS-DESTRUCTIVE` | Supported guest zero-data writes use ordinary COW and do not abort every update. Unsupported DSM/discard/write-zeroes opcodes reach no storage mutation. Administrative Recover/reset/BASE still invalidate and drain; progress assumes these lifecycle transitions eventually stop. | M1 Write / M5 Save | `chunk_cut_cow.go` `beforeCOWMutation`; frontend dispatch | `TestCutCOWV3_ZeroWritesDoNotAbortUpdates` (`core/storage/chunk_cut_alignment_test.go`); `TestDispatch_UnsupportedOperations` (`core/frontend/ublk/dispatch_test.go`); `TestT2Batch11a_IdentifyController_ONCSAllZero` (`core/frontend/nvme/identify_test.go`) | Guest/lifecycle distinction not modelled; native controls | ACTIVE |
|
||||
| `INV-CUT-PAYLOAD-BOUNDED-001` | Upload workers, active savers and cached saves share a configurable per-volume payload byte bound independent of candidate count; an explicit budget below six chunks is refused. An optional Budget admits before staging/barrier and accounts each COW save without a window lock; revocation aborts only the cut and its ticket is released after worker joins. Host-wide policy is a separate limiter module. Pre-copy streams one chunk per worker; native at-H reads protect unsent candidates with COW. Only guest overwrites consume side-file bytes. A full side-file cap aborts the update, retains its dirty set and allows guest writes to proceed. Uploads join before cleanup. | M5 Stage / Copy / Upload | `chunk_cut_payload.go`; `chunk_cut_cow.go`; `chunk_upload.go` | `TestCutBudgetRefusesBeforeBarrier`, `TestCutBudgetCOWRefusalAbortsOnlyCut`, `TestCutBudgetRevocationJoinsBeforeRelease` (`core/storage/chunk_cut_budget_test.go`); `TestCutPayloadBudgetBoundsSlots`, `TestChunkLayerPayloadBudgetRejectsUndersized` (`core/storage/chunk_cut_payload_budget_test.go`); `TestWALStoreChunk_InitialWriteAnonymousMemory` (isolated Linux RSS arms, `core/frontend/durable/provider_initial_memory_linux_test.go`); `TestCutCOWV3_ChangedImageExceedsSpillCap`, `TestChunkStageV3_ChangedImageExceedsSpillCap`, `TestCutCOWV3_OverwriteStormAbortsAndRetries`, `TestCutCOWV3_RemoteUploadDoesNotParkCopiedChunk` (`core/storage/chunk_cut_cow_spillcap_test.go`); `TestChunkUploads_FailureJoinsBeforeIntentCleanup` (`core/storage/chunk_upload_parallel_test.go`) | `CutPipeline` `AbortPoint` covers refused-point stutter; byte counts and filesystem/transport resource costs are not modelled | ACTIVE |
|
||||
| `INV-CUT-INTENT-FIRST-001` | Before the first upload of a cut, an intent naming every new key is durable, and it is removed only after the CAS outcome is known. | M5 Intent → Upload → CAS | `core/storage/chunk_layer.go` `captureLocked`, `stage`; `core/frontend/chunkstore/manifest.go` `PrepareManifest` | `TestChunkIntent_WrittenBeforeFirstUploadAndDeletedAfterCAS` (`core/storage/chunk_layer_intent_test.go`); `TestChunkPrecopy_StagedUploadsAreCoveredByIntents` (`core/storage/chunk_layer_precopy_test.go`) | `ChunkLifecycleFixed` `GCSafe`; `WorkspaceTakeover` `NoLiveIntentExpired` | ACTIVE |
|
||||
| `INV-CUT-PAYLOAD-BOUNDED-001` | Upload workers, active savers and cached saves share a configurable per-volume payload byte bound independent of candidate count; an explicit budget below six chunks is refused. An optional Budget admits before staging/barrier and accounts each COW save without a window lock; revocation aborts only the cut and its ticket is released after worker joins. Host-wide policy is a separate limiter module. WAL batch validation uses block-sized scratch even when a record spans many chunks. Pre-copy streams one chunk per worker; native at-H reads protect unsent candidates with COW. Only guest overwrites consume side-file bytes. A full side-file cap aborts the update, retains its dirty set and allows guest writes to proceed. Uploads join before cleanup. | M5 Stage / Copy / Upload | `chunk_cut_payload.go`; `chunk_cut_cow.go`; `chunk_upload.go` | `TestCutBudgetRefusesBeforeBarrier`, `TestCutBudgetCOWRefusalAbortsOnlyCut`, `TestCutBudgetRevocationJoinsBeforeRelease` (`core/storage/chunk_cut_budget_test.go`); `TestV3ReadLargeBatchScratchIsBlockBounded`, `TestCutAbortReasonsAreCountedAndCopied`, `TestCutPayloadBudgetBoundsSlots`, `TestChunkLayerPayloadBudgetRejectsUndersized` (`core/storage/chunk_cut_payload_budget_test.go`); `TestWALStoreChunk_InitialWriteAnonymousMemory` (isolated Linux RSS arms, `core/frontend/durable/provider_initial_memory_linux_test.go`); `TestCutCOWV3_ChangedImageExceedsSpillCap`, `TestChunkStageV3_ChangedImageExceedsSpillCap`, `TestCutCOWV3_OverwriteStormAbortsAndRetries`, `TestCutCOWV3_RemoteUploadDoesNotParkCopiedChunk` (`core/storage/chunk_cut_cow_spillcap_test.go`); `TestChunkUploads_FailureJoinsBeforeIntentCleanup` (`core/storage/chunk_upload_parallel_test.go`) | `CutPipeline` `AbortPoint` covers refused-point stutter; byte counts and filesystem/transport resource costs are not modelled | ACTIVE |
|
||||
| `INV-CUT-INTENT-FIRST-001` | Before the first upload of a cut or staging round, one intent names every preallocated candidate key (unused keys are harmless), independent of upload wave count. Known-aborted reusable roots are removed at clean Close; unresolved CAS roots remain protected. Intent removal follows a known CAS outcome. | M5 Intent → Upload → CAS | `core/storage/chunk_layer.go` `captureLocked`, `stage`; `core/frontend/chunkstore/manifest.go` `PrepareManifest` | `TestCutPayloadIntentCountIndependentOfCandidates`, `TestChunkCloseDropsReusableButKeepsUnknownCASRoots`, `TestChunkIntent_WrittenBeforeFirstUploadAndDeletedAfterCAS` (`core/storage/chunk_layer_intent_test.go`); `TestChunkPrecopy_StagedUploadsAreCoveredByIntents` (`core/storage/chunk_layer_precopy_test.go`) | `ChunkLifecycleFixed` `GCSafe`; `WorkspaceTakeover` `NoLiveIntentExpired` | ACTIVE |
|
||||
| `INV-CUT-SEGMENT-REUSE-001` | A cut rewrites only manifest segments whose chunk references changed, and an uploaded but unpublished segment leaves the published root unchanged. | M5 Manifest | `core/frontend/chunkstore/manifest.go` `PrepareManifest` | `TestManifest_ReusesUnchangedRangeAndCrashKeepsOldRoot` (`core/frontend/chunkstore/manifest_test.go`) | `CutPipeline` `SegConsistent` | ACTIVE |
|
||||
| `INV-CUT-HYDRATION-WAIT-001` | A read command shares its arrival deadline across chunks. A timed-out waiter returns typed pending without cancelling a shared fill. Per-layer worker and distinct-flight limits bound remote work; Close wakes waiters and joins issued fills before storage release. Physical/hash errors remain terminal. | M4 Holder (hydration wait) | `core/storage/chunk_hydration.go`; `core/storage/walstore.go` `ReadContext`; `core/frontend/durable/storage_adapter.go` `readStorageBlock`; `core/frontend/nvme/session.go` `handleRead` | `TestDurableHydration_MultipleChunksShareOneDeadline`, `TestDurableHydration_NVMePreservesPhysicalAndHashErrors`, `TestSessionReadBudgetIncludesQueueResidence`, `TestChunkHydration_QueueAndWorkerLimitsAreBounded`, `TestChunkHydration_CloseWakesCallerAndJoinsUninterruptibleGet`, `TestChunkHydration_ContextlessReadAllowsSlowFill`, `TestChunkHydration_NewGenerationDoesNotJoinStaleGet`, `TestChunkHydration_StaleCompletionKeepsReplacement`, `TestDurableHydration_RMWFenceWinsCallerExpiry` | — | ACTIVE |
|
||||
| `INV-CUT-READMISS-001` | A block fetched from HEAD after a move is installed only if it does not overwrite a newer local extent version; a newer WAL-only write still wins on reads, and HEAD's value may be installed beneath it as the backing value, which is correct if a crash loses that unsynced write. | M4 Holder (lazy restore) | `core/storage/chunk_layer.go` `OnReadMiss`, `installFetchedBlock`; `core/storage/walstore.go` `readFromExtent` | `TestChunkLayer_WALOnlyOverlapReadNeverReturnsUntouchedZero` (`core/storage/chunk_layer_races_test.go`); `TestWALStore_PostReadMissRechecksWALFormat` (`core/storage/walstore_read_miss_v3_test.go`; real-store v2/v3 dispatch, v3 remains dark) | — | ACTIVE |
|
||||
|
||||
Reference in new issue
Block a user