mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 18:47:20 +01:00
test: expose concurrent snapshot operation capacity overflow
This commit is contained in:
1 parent
a375d7bf5e
commit
cee64dbaa8
2 files changed
+60
No files matched your search
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
// The durable bound includes accepted, running and stalled records. Reopening
|
||||
@@ -53,3 +54,61 @@ func TestSnapshotOperationRetirementFullPendingRefusesWithoutLosingReceipt(t *te
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Separate store instances represent independent executors sharing the same
|
||||
// filer. A process-local queue or mutex cannot be the durable admission bound.
|
||||
func TestSnapshotOperationRetirementConcurrentAdmissionsShareLastSlot(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
_, _, store, _ := cleanFixture(t)
|
||||
fingerprint := strings.Repeat("a", 64)
|
||||
for i := range 4095 {
|
||||
if _, created, err := store.CreateSnapshotOperation(ctx, fmt.Sprintf("pending-%04d", i), "create", "daily", fingerprint); err != nil || !created {
|
||||
t.Fatalf("seed %d: created=%v err=%v", i, created, err)
|
||||
}
|
||||
}
|
||||
const contenders = 32
|
||||
stores := make([]*LayoutStore, contenders)
|
||||
for i := range stores {
|
||||
var err error
|
||||
stores[i], err = NewLayoutStore(store.f, store.b, store.root, store.id)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
type answer struct {
|
||||
id string
|
||||
created bool
|
||||
err error
|
||||
}
|
||||
start := make(chan struct{})
|
||||
answers := make(chan answer, contenders)
|
||||
for i, independent := range stores {
|
||||
go func() {
|
||||
<-start
|
||||
id := fmt.Sprintf("contender-%02d", i)
|
||||
_, created, err := independent.CreateSnapshotOperation(ctx, id, "create", "daily", fingerprint)
|
||||
answers <- answer{id, created, err}
|
||||
}()
|
||||
}
|
||||
close(start)
|
||||
admitted := 0
|
||||
for range contenders {
|
||||
result := <-answers
|
||||
if result.err == nil && result.created {
|
||||
admitted++
|
||||
} else {
|
||||
var refusal *CatalogError
|
||||
if result.created || !errors.As(result.err, &refusal) || refusal.Code != "operation_capacity" || !refusal.Retryable {
|
||||
t.Errorf("unexpected competing admission answer: %+v", result)
|
||||
}
|
||||
}
|
||||
_, found, err := store.ReadSnapshotOperation(ctx, result.id, "create")
|
||||
if err != nil || found != result.created {
|
||||
t.Errorf("answer and durable receipt disagree for %s: created=%v found=%v err=%v", result.id, result.created, found, err)
|
||||
}
|
||||
}
|
||||
if admitted != 1 {
|
||||
t.Fatalf("4095 pending receipts leave one shared slot, but %d of %d independent admissions succeeded", admitted, contenders)
|
||||
}
|
||||
}
|
||||
@@ -1292,6 +1292,7 @@ Notes:
|
||||
| `INV-SNAP-OP-TERMINAL-WRITERS-001` | Snapshot operation success settles a HEAD binding. A terminal refusal is a HEAD conflict checked before provider execution; a provider error can only stall or leave the receipt unchanged. | M9 operation terminal outcome | `LayoutStore.SettleSnapshotOperationFromHead`, `chunkControl.snapshotOperationAttempt` | `TestSnapshotOperationTerminalWriterEnumeration`, `TestSnapshotOperationAppliedAnswerFailureNeverBecomesRefused`, `TestSnapshotOperationFencedFailurePreservesPublishedBinding` | SnapOps run3 row 218; split-publication refinement pending | STUB |
|
||||
| `INV-SNAP-OP-WORKER-001` | A synchronous retry of an in-flight operation reads its receipt and replays a terminal outcome or refuses retryably, without starting another provider attempt. Changed intent still refuses before work. | M9 operation executor | `chunkControl.Snapshot`, `snapshotOperationInFlight`, process-local `opJobs` | `TestSnapshotOperationSynchronousRetryDoesNotDuplicateAsyncWorker` | SnapOps.Start; complete executor qualification pending | STUB |
|
||||
| `INV-SNAP-OP-CAPACITY-001` | At 4096 nonterminal receipts, new snapshot-operation admission refuses retryably without a record; retained accepted and stalled operations still replay after reopening. | M9 operation admission (planned) | `LayoutStore.CreateSnapshotOperation` (durable capacity implementation pending) | `TestSnapshotOperationRetirementFullPendingRefusesWithoutLosingReceipt` | SnapOps total-record bound; pending-never-retires control (red) | STUB |
|
||||
| `INV-SNAP-OP-CONCURRENT-CAPACITY-001` | Concurrent admissions through independent volume stores share the durable 4096-record limit; with 4095 pending receipts, only one new request is admitted. | M9 operation admission (planned) | `LayoutStore.CreateSnapshotOperation` (durable index implementation pending) | `TestSnapshotOperationRetirementConcurrentAdmissionsShareLastSlot` | SnapOps total-record bound; index refinement pending (red) | STUB |
|
||||
| `INV-SNAP-OP-ORIGINAL-001` | Within the retained operation window, retrying a snapshot create returns its original outcome after control, catalog or retention removal, and after name reuse; it performs no new cut or HEAD write. | M9 operation replay (planned) | `chunkControl.Snapshot`, shared HEAD/receipt guard and process-owned executor; retirement pending | `TestSnapshotOperationRetryAfterRemovalKeepsOriginalOutcome`, `TestSnapshotOperationOldIDDoesNotAliasReusedName` (`core/host/volume/snapshot_operation_red_test.go`) | SnapOps.Send/Publish/Delete; rows 211–219 (first red tranche only) | STUB |
|
||||
| `INV-SNAP-OP-FINGERPRINT-001` | A retained operation ID reused with changed snapshot intent refuses before any cut or HEAD write. | M9 operation admission (planned) | `CreateSnapshotOperation` canonical fingerprint; create executor wired; delete executor pending | `TestSnapshotOperationSameIDChangedIntentRefusesBeforeWrite` (`core/host/volume/snapshot_operation_red_test.go`) | SnapOps.Send; rows 211–219 | STUB |
|
||||
| `INV-SNAP-OP-READMIT-001` | A create whose HEAD publication applied before its answer was lost reconciles that original outcome on re-admission; later removal cannot cause another execution under its retained operation ID. | M9 operation re-admission (planned) | `SnapshotOperationBinding`, `LayoutStore.GuardSnapshotOperations`; create executor wired; retirement pending | `TestSnapshotOperationLostPublishAnswerReadmitDeleteCannotRepublish`, `TestSnapshotOperationRemovalBeforeReadmitKeepsPublishedOutcome` (`core/host/volume/snapshot_operation_red_test.go`) | SnapOps.Send/Publish/Settle/Delete; rows 211–219 (persisted-stall removal controls included; concurrent-owner controls pending) | STUB |
|
||||
|
||||
Reference in new issue
Block a user