mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-06 02:57:37 +01:00
Merge pull request #321 from seaweedfs/train/20261121-4
Train 4: #319 + #316
This commit is contained in:
commit
2d345a3663
19 files changed
+430
-101
No files matched your search
@@ -201,6 +201,7 @@ func parseFlags(args []string) (flags, error) {
|
||||
fs.StringVar(&f.chunk.path, "chunk-path", defaultChunkPath, "walstore-chunk: filer directory holding one directory per volume (HEAD and chunk key bindings)")
|
||||
fs.StringVar(&f.chunk.collection, "chunk-collection", "", "walstore-chunk: collection for chunk needles (empty = filer default / storage rule)")
|
||||
fs.StringVar(&f.chunk.replication, "chunk-replication", "", "walstore-chunk: replication for chunk needles (empty = filer default / storage rule)")
|
||||
fs.Bool("chunk-detach-plain-supported", false, "capability: supports idle plain=true on /chunk/detach (no-op flag)")
|
||||
fs.BoolVar(&f.chunk.detachPrecopy, "chunk-detach-precopy", false, "walstore-chunk: converge rolling cuts before final detach; refuse cutover if measured tail does not fit")
|
||||
fs.DurationVar(&f.chunk.captureInterval, "chunk-capture-interval", defaultChunkCaptureInterval, "walstore-chunk: automatic cut once this long has passed since the last successful cut; 0 (default) disables the timer, e.g. 15m as a host-loss safety net")
|
||||
fs.IntVar(&f.chunk.uploadConcurrency, "chunk-upload-concurrency", 8, "walstore-chunk: maximum concurrent dirty-chunk uploads (1..64)")
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPlainDetachCapabilityFlagIsNoop(t *testing.T) {
|
||||
base := []string{"--master", "127.0.0.1:1", "--server-id", "h1", "--volume-id", "v1", "--replica-id", "r1", "--data-addr", "127.0.0.1:2", "--ctrl-addr", "127.0.0.1:3"}
|
||||
want, err := parseFlags(base)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, arg := range []string{"--chunk-detach-plain-supported", "--chunk-detach-plain-supported=true", "--chunk-detach-plain-supported=false"} {
|
||||
got, err := parseFlags(append(append([]string{}, base...), arg))
|
||||
if err != nil {
|
||||
t.Fatalf("capability flag unavailable: %s: %v", arg, err)
|
||||
}
|
||||
if !reflect.DeepEqual(got, want) {
|
||||
t.Fatalf("capability flag changed runtime configuration: %s", arg)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -129,10 +129,13 @@ func TestPrecopyLateGateCallerCannotCrossFreeze(t *testing.T) {
|
||||
}
|
||||
select {
|
||||
case <-done:
|
||||
if !errors.Is(writeErr, frontend.ErrBackendClosed) {
|
||||
// Capture can outlast this caller's budget before Close. The exact
|
||||
// two orderings are witnessed by TestPrecopyCallerExpiryVersusClose.
|
||||
expired := errors.Is(ctx.Err(), context.DeadlineExceeded) && errors.Is(writeErr, frontend.ErrBackendBusy) && errors.Is(writeErr, context.DeadlineExceeded)
|
||||
if !errors.Is(writeErr, frontend.ErrBackendClosed) && !expired {
|
||||
t.Fatal(writeErr)
|
||||
}
|
||||
case <-ctx.Done():
|
||||
case <-time.After(time.Second):
|
||||
t.Fatal("closed path did not settle late command")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package durable
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/seaweedfs/seaweed-block/core/frontend"
|
||||
"testing"
|
||||
"testing/synctest"
|
||||
"time"
|
||||
)
|
||||
|
||||
// The LateGate failure is this ordering: a queued command's caller budget
|
||||
// expires during capture, before Close. Close cannot rewrite its completed Busy.
|
||||
func TestPrecopyCallerExpiryVersusClose(t *testing.T) {
|
||||
for _, closeFirst := range []bool{false, true} {
|
||||
name := "expiry-before-close"
|
||||
if closeFirst {
|
||||
name = "close-before-expiry"
|
||||
}
|
||||
t.Run(name, func(t *testing.T) {
|
||||
synctest.Test(t, func(t *testing.T) {
|
||||
b := precopyMemoryBackend(t)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
queued := make(chan struct{})
|
||||
done := make(chan error, 1)
|
||||
b.testPrecopyQueued = func() { close(queued) }
|
||||
if !b.TryStopIO("held capture") {
|
||||
t.Fatal("freeze refused")
|
||||
}
|
||||
before := b.storage.NextLSN()
|
||||
go func() { _, err := b.Write(ctx, 0, make([]byte, 4096)); done <- err }()
|
||||
joined := false
|
||||
t.Cleanup(func() {
|
||||
cancel()
|
||||
_ = b.Close()
|
||||
if !joined {
|
||||
select {
|
||||
case <-done:
|
||||
case <-time.After(time.Second):
|
||||
t.Error("queued command did not settle")
|
||||
}
|
||||
}
|
||||
})
|
||||
select {
|
||||
case <-queued:
|
||||
case <-time.After(time.Second):
|
||||
t.Fatal("queue not witnessed")
|
||||
}
|
||||
synctest.Wait()
|
||||
if closeFirst {
|
||||
if err := b.Close(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
} else {
|
||||
time.Sleep(time.Second)
|
||||
}
|
||||
synctest.Wait()
|
||||
var err error
|
||||
select {
|
||||
case err = <-done:
|
||||
joined = true
|
||||
case <-time.After(time.Second):
|
||||
t.Fatal("chosen boundary did not settle command")
|
||||
}
|
||||
if closeFirst {
|
||||
if !errors.Is(err, frontend.ErrBackendClosed) || ctx.Err() != nil {
|
||||
t.Fatalf("Close failed to win before live deadline: %v ctx=%v", err, ctx.Err())
|
||||
}
|
||||
} else {
|
||||
if !errors.Is(err, frontend.ErrBackendBusy) || !errors.Is(err, context.DeadlineExceeded) || errors.Is(err, frontend.ErrBackendClosed) {
|
||||
t.Fatalf("expiry before Close misclassified: %v", err)
|
||||
}
|
||||
if e := b.Close(); e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
}
|
||||
if b.storage.NextLSN() != before {
|
||||
t.Fatal("queued command appended storage")
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -306,16 +306,26 @@ func precopyFiftyAttemptError(round storage.PrecopyAttempt, previous *storage.Pr
|
||||
return nil
|
||||
}
|
||||
const allowance = 1200 * time.Millisecond
|
||||
eligible := round.Estimate <= allowance
|
||||
if round.Reason == "samples_unknown" {
|
||||
if round.Frozen || round.DeclaredFreeze != 0 || round.Error != "" {
|
||||
return fmt.Errorf("unknown sample admitted: %+v", round)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
eligible := round.Estimate > 0 && round.Estimate <= allowance
|
||||
reason := "fit"
|
||||
if !eligible && previous != nil && round.TailEstimate <= allowance/4 && round.Estimate >= previous.Estimate && round.Estimate <= 5*time.Second {
|
||||
eligible, reason = true, "fixed_cost_over_allowance"
|
||||
if !eligible && round.Estimate > 0 && round.Estimate <= 5*time.Second {
|
||||
if precopyFiftyPreviousKnown(previous) && round.Estimate >= previous.Estimate-previous.Estimate/10 {
|
||||
eligible, reason = true, "no_progress"
|
||||
} else if round.Attempt == 5 {
|
||||
eligible, reason = true, "final_attempt"
|
||||
}
|
||||
}
|
||||
if round.Frozen {
|
||||
if !eligible || !last || round.Reason != reason || round.DeclaredFreeze != round.Estimate || round.Error != "" {
|
||||
return fmt.Errorf("invalid fitting attempt: %+v", round)
|
||||
}
|
||||
} else if eligible || (round.Reason != "tail_too_large" && round.Reason != "barrier_over_budget" && round.Reason != "fixed_cost_exceeds_freeze_budget") || round.Error != "" {
|
||||
} else if eligible || (round.Reason != "tail_too_large" && round.Reason != "barrier_over_budget" && round.Reason != "freeze_budget_exceeded") || round.Error != "" {
|
||||
return fmt.Errorf("refused an eligible attempt or hid a failure: %+v", round)
|
||||
}
|
||||
return nil
|
||||
@@ -348,3 +358,14 @@ func TestPrecopyFiftyIOPSDrainRefusalDoesNotClaimAdmission(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func precopyFiftyPreviousKnown(a *storage.PrecopyAttempt) bool {
|
||||
if a == nil || a.Estimate <= 0 || a.Error != "" {
|
||||
return false
|
||||
}
|
||||
switch a.Reason {
|
||||
case "fit", "tail_too_large", "barrier_over_budget", "freeze_budget_exceeded", "no_progress", "final_attempt", "admitted_io":
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -245,7 +245,7 @@ func precopyBusyOwnerKeepsServing(t *testing.T, delay time.Duration) {
|
||||
// Releasing the owner does not erase a slow sample. Admission must
|
||||
// still refuse a tail-bound point; a small stalled tail can now declare
|
||||
// the retained fixed-cost exception instead of recopying indefinitely.
|
||||
if !errors.Is(err, storage.ErrPrecopyNotConverged) || r.Precopy.Frozen || r.Precopy.Estimate <= 1200*time.Millisecond || (r.Precopy.Reason != "tail_too_large" && r.Precopy.Reason != "barrier_over_budget" && r.Precopy.Reason != "fixed_cost_exceeds_freeze_budget") {
|
||||
if !errors.Is(err, storage.ErrPrecopyNotConverged) || r.Precopy.Frozen || r.Precopy.Estimate <= 1200*time.Millisecond || (r.Precopy.Reason != "tail_too_large" && r.Precopy.Reason != "barrier_over_budget" && r.Precopy.Reason != "freeze_budget_exceeded") {
|
||||
t.Fatalf("post-release retry violated measured admission: report=%+v err=%v", r.Precopy, err)
|
||||
}
|
||||
if delay > 0 && r.Precopy.Fixed < delay {
|
||||
@@ -260,7 +260,7 @@ func precopyBusyOwnerKeepsServing(t *testing.T, delay time.Duration) {
|
||||
t.Fatalf("over-budget retry failed to resume service: n=%d err=%v", n, e)
|
||||
}
|
||||
} else if delay > 0 {
|
||||
if !r.Precopy.Frozen || r.Precopy.Reason != "fixed_cost_over_allowance" || r.Precopy.Fixed < delay || r.Precopy.TailEstimate > 300*time.Millisecond || r.Precopy.PreviousEstimate <= 0 || r.Precopy.Estimate < r.Precopy.PreviousEstimate || r.Precopy.Estimate > 5*time.Second || r.Precopy.DeclaredFreeze != r.Precopy.Estimate {
|
||||
if !r.Precopy.Frozen || r.Precopy.Reason != "no_progress" || r.Precopy.Fixed < delay || r.Precopy.PreviousEstimate <= 0 || r.Precopy.Estimate < r.Precopy.PreviousEstimate-r.Precopy.PreviousEstimate/10 || r.Precopy.Estimate > 5*time.Second || r.Precopy.DeclaredFreeze != r.Precopy.Estimate {
|
||||
t.Fatalf("slow retry bypassed the declared small-tail plateau rule: %+v", r.Precopy)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@ const (
|
||||
precopyMargin = 100 * time.Millisecond
|
||||
precopyDrainBound = 100 * time.Millisecond
|
||||
precopyFreezeLimit = 5 * time.Second
|
||||
precopyFixedWindow = 5
|
||||
precopyFixedMaxAge = 15 * time.Minute
|
||||
)
|
||||
|
||||
// PrecopyFixedParts are disjoint terms of the same retained fixed-cost sample.
|
||||
@@ -101,7 +103,7 @@ func (r *PrecopyReport) Finish(elapsed time.Duration, extraCAS uint64, failed bo
|
||||
r.CASFailureTimeout = chunkHeadOperationTimeout
|
||||
r.DeclaredWorst = r.Estimate + time.Duration(extraCAS)*chunkHeadOperationTimeout
|
||||
limit := precopyAllowance
|
||||
if r.Reason == "fixed_cost_over_allowance" {
|
||||
if r.Reason == "no_progress" || r.Reason == "final_attempt" {
|
||||
limit = min(r.DeclaredFreeze, precopyFreezeLimit)
|
||||
}
|
||||
r.LatencyGateFailed = failed || elapsed > limit
|
||||
@@ -194,7 +196,7 @@ func (l *chunkLayerImpl) precopyDetach(ctx context.Context, prepare func(context
|
||||
if len(rounds) > 0 {
|
||||
previous = &rounds[len(rounds)-1]
|
||||
}
|
||||
if !report.admitPrecopy(previous) {
|
||||
if !report.admitPrecopy(previous, len(rounds)+1 == precopyAttempts) {
|
||||
return false
|
||||
}
|
||||
report.DeclaredFreeze = report.Estimate
|
||||
@@ -276,30 +278,34 @@ func (l *chunkLayerImpl) precopyEstimate(tail uint64, attempts int) PrecopyRepor
|
||||
r := PrecopyReport{Attempts: attempts, TailBytes: tail, Reason: "samples_unknown"}
|
||||
now := time.Now()
|
||||
var rates []float64
|
||||
for _, s := range l.precopySamples {
|
||||
age := now.Sub(s.at)
|
||||
if age > precopyDuration {
|
||||
// Fixed work uses up to the last five fresh observations, independent of the
|
||||
// latest-three-rate window. Parts always belong to the selected observation.
|
||||
fixedCount := 0
|
||||
for i := len(l.precopySamples) - 1; i >= 0; i-- {
|
||||
sample := l.precopySamples[i]
|
||||
age := now.Sub(sample.at)
|
||||
if age < 0 {
|
||||
continue
|
||||
}
|
||||
if age > r.SampleAge {
|
||||
r.SampleAge = age
|
||||
if age <= precopyDuration && sample.rate > 0 {
|
||||
rates = append(rates, sample.rate)
|
||||
}
|
||||
// With at most 32 observations the maximum is a conservative empirical
|
||||
// p99 envelope of barrier-to-settlement non-payload work. Serving
|
||||
// preparation and host-budget waits are outside the freeze. The stop
|
||||
// is already drained; metadata and CAS/read-back remain included.
|
||||
if s.fixed > r.Fixed {
|
||||
r.Fixed = s.fixed
|
||||
r.FixedParts = s.parts
|
||||
known := s.parts.Drain + s.parts.StoreLock + s.parts.DataSync + s.parts.HeadCAS + s.parts.HeadReadback + s.parts.MapPersist
|
||||
r.FixedParts.Other = max(time.Duration(0), s.fixed-known)
|
||||
if age >= precopyFixedMaxAge || fixedCount >= precopyFixedWindow {
|
||||
continue
|
||||
}
|
||||
if s.rate > 0 {
|
||||
rates = append(rates, s.rate)
|
||||
fixedCount++
|
||||
r.SampleAge = max(r.SampleAge, age)
|
||||
if sample.fixed > r.Fixed {
|
||||
r.Fixed = sample.fixed
|
||||
r.FixedParts = precopyFixedPartsFromSample(sample)
|
||||
}
|
||||
}
|
||||
// Rates were visited newest first; only the latest three are used below.
|
||||
r.RateSamples = len(rates)
|
||||
if r.Fixed <= 0 {
|
||||
if len(rates) > 3 {
|
||||
rates = rates[:3]
|
||||
}
|
||||
if fixedCount == 0 || r.Fixed <= 0 {
|
||||
return r
|
||||
}
|
||||
r.Estimate = r.Fixed + precopyMargin
|
||||
@@ -331,29 +337,41 @@ func (l *chunkLayerImpl) precopyEstimate(tail uint64, attempts int) PrecopyRepor
|
||||
return r
|
||||
}
|
||||
|
||||
// More copying cannot reduce a fixed-bound plateau. Only the measured tail
|
||||
// may use at most a quarter of the normal allowance on this exception path.
|
||||
func (r *PrecopyReport) admitPrecopy(previous *PrecopyAttempt) bool {
|
||||
if r.Reason == "fit" && r.Estimate <= precopyAllowance {
|
||||
// Rounds shrink the tail; a plateau or the final round may use the full
|
||||
// declared freeze budget. The final flag is the physical round, not the number
|
||||
// of warm admission attempts (measurement rounds consume the same limit).
|
||||
func (r *PrecopyReport) admitPrecopy(previous *PrecopyAttempt, final bool) bool {
|
||||
if r.Reason == "samples_unknown" || r.Estimate <= 0 {
|
||||
return false
|
||||
}
|
||||
if r.Estimate <= precopyAllowance {
|
||||
r.Reason = "fit"
|
||||
return true
|
||||
}
|
||||
if r.Reason == "samples_unknown" {
|
||||
if r.Estimate > precopyFreezeLimit {
|
||||
r.Reason = "freeze_budget_exceeded"
|
||||
return false
|
||||
}
|
||||
// Preserve and name the existing frontend ceiling even on the first round.
|
||||
if r.TailEstimate <= precopyAllowance/4 && r.Estimate > precopyFreezeLimit {
|
||||
r.Reason = "fixed_cost_exceeds_freeze_budget"
|
||||
return false
|
||||
if comparablePrecopyAttempt(previous) {
|
||||
r.PreviousEstimate = previous.Estimate
|
||||
// Division first avoids overflow while retaining nanosecond precision.
|
||||
threshold := previous.Estimate - previous.Estimate/10
|
||||
if r.Estimate >= threshold {
|
||||
r.Reason = "no_progress"
|
||||
return true
|
||||
}
|
||||
}
|
||||
if previous == nil || previous.Estimate <= 0 {
|
||||
return false
|
||||
if final {
|
||||
r.Reason = "final_attempt"
|
||||
return true
|
||||
}
|
||||
r.PreviousEstimate = previous.Estimate
|
||||
if r.TailEstimate > precopyAllowance/4 || r.Estimate < previous.Estimate {
|
||||
return false
|
||||
}
|
||||
r.Reason = "fixed_cost_over_allowance"
|
||||
return true
|
||||
return false
|
||||
}
|
||||
|
||||
func precopyFixedPartsFromSample(s precopySample) PrecopyFixedParts {
|
||||
p := s.parts
|
||||
p.Other = max(time.Duration(0), s.fixed-p.Drain-p.StoreLock-p.DataSync-p.HeadCAS-p.HeadReadback-p.MapPersist)
|
||||
return p
|
||||
}
|
||||
|
||||
func (l *chunkLayerImpl) samplePrecopy(st chunkCutStats, fixedNs int64) {
|
||||
@@ -394,3 +412,17 @@ func (l *chunkLayerImpl) lockPrecopy(ctx context.Context) error {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Only a completed cost estimate is comparable. A drain/before-barrier refusal
|
||||
// can carry Fixed+margin without a known tail, just like samples_unknown.
|
||||
func comparablePrecopyAttempt(a *PrecopyAttempt) bool {
|
||||
if a == nil || a.Estimate <= 0 || a.Error != "" {
|
||||
return false
|
||||
}
|
||||
switch a.Reason {
|
||||
case "fit", "tail_too_large", "barrier_over_budget", "freeze_budget_exceeded", "no_progress", "final_attempt", "admitted_io":
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestPrecopySmokeTraceAmendment4(t *testing.T) {
|
||||
estimates := []time.Duration{1475267, 1465874, 1733371, 1733371, 1733371}
|
||||
tails := []time.Duration{140090, 130697, 398194, 398194, 398194}
|
||||
var previous *PrecopyAttempt
|
||||
for i, e := range estimates {
|
||||
r := PrecopyReport{Fixed: 1235177 * time.Microsecond, Estimate: e * time.Microsecond, TailEstimate: tails[i] * time.Microsecond, Reason: "tail_too_large"}
|
||||
if r.admitPrecopy(previous, i == 4) {
|
||||
if i > 2 || r.Reason != "no_progress" {
|
||||
t.Fatalf("late/wrong admission round%d: %+v", i+1, r)
|
||||
}
|
||||
return
|
||||
}
|
||||
previous = &PrecopyAttempt{Reason: "tail_too_large", Estimate: r.Estimate}
|
||||
}
|
||||
t.Fatal("smoke trace refused despite no meaningful progress within freeze bound")
|
||||
}
|
||||
func TestPrecopyFixedWindowDecays(t *testing.T) {
|
||||
_, _, l, _ := precopyLayer(t, 1024, 0)
|
||||
now := time.Now()
|
||||
l.precopySamples = nil
|
||||
l.precopySamples = append(l.precopySamples, precopySample{at: now, fixed: 1235 * time.Millisecond})
|
||||
for i := 0; i < 5; i++ {
|
||||
l.precopySamples = append(l.precopySamples, precopySample{at: now, fixed: 100 * time.Millisecond, rate: 1e9})
|
||||
}
|
||||
if r := l.precopyEstimate(0, 0); r.Fixed != 100*time.Millisecond {
|
||||
t.Fatalf("old peak retained: %+v", r)
|
||||
}
|
||||
l.precopySamples = l.precopySamples[1:]
|
||||
l.precopySamples[0].at = now.Add(-16 * time.Minute)
|
||||
if r := l.precopyEstimate(0, 0); r.Fixed != 100*time.Millisecond || r.Reason == "samples_unknown" {
|
||||
t.Fatalf("available fresh samples were refused: %+v", r)
|
||||
}
|
||||
for i := range l.precopySamples {
|
||||
l.precopySamples[i].at = now.Add(-16 * time.Minute)
|
||||
}
|
||||
if r := l.precopyEstimate(0, 0); r.Reason != "samples_unknown" {
|
||||
t.Fatalf("expired samples admitted: %+v", r)
|
||||
}
|
||||
l.precopySamples = []precopySample{{at: now, fixed: 100 * time.Millisecond}}
|
||||
if r := l.precopyEstimate(0, 0); r.Fixed != 100*time.Millisecond || r.Reason != "fit" {
|
||||
t.Fatalf("single fresh fixed observation refused: %+v", r)
|
||||
}
|
||||
}
|
||||
func TestPrecopyFinalAttemptFreezeCeiling(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
estimate time.Duration
|
||||
want bool
|
||||
}{{4500 * time.Millisecond, true}, {5500 * time.Millisecond, false}} {
|
||||
r := PrecopyReport{Estimate: tc.estimate, TailEstimate: 3 * time.Second, Reason: "tail_too_large"}
|
||||
previous := &PrecopyAttempt{Reason: "tail_too_large", Estimate: 6 * time.Second}
|
||||
if got := r.admitPrecopy(previous, true); got != tc.want {
|
||||
t.Fatalf("final admission=%t want=%t: %+v", got, tc.want, r)
|
||||
}
|
||||
if tc.want && r.Reason != "final_attempt" {
|
||||
t.Fatalf("wrong final reason: %+v", r)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestPrecopyAmendment4AdmissionBoundaries(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
estimate, previous time.Duration
|
||||
final bool
|
||||
reason string
|
||||
}{
|
||||
{"fit", time.Second, 0, false, "fit"},
|
||||
{"ten-percent", 1800 * time.Millisecond, 2 * time.Second, false, "no_progress"},
|
||||
{"meaningful", 1800*time.Millisecond - 1, 2 * time.Second, false, "tail_too_large"},
|
||||
{"final-no-history", 4 * time.Second, 0, true, "final_attempt"},
|
||||
{"ceiling", 5 * time.Second, 0, true, "final_attempt"},
|
||||
{"over-ceiling", 5*time.Second + 1, 6 * time.Second, true, "freeze_budget_exceeded"},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
r := PrecopyReport{Estimate: tc.estimate, Reason: "tail_too_large"}
|
||||
var prev *PrecopyAttempt
|
||||
if tc.previous > 0 {
|
||||
prev = &PrecopyAttempt{Reason: "tail_too_large", Estimate: tc.previous}
|
||||
}
|
||||
got := r.admitPrecopy(prev, tc.final)
|
||||
want := tc.reason == "fit" || tc.reason == "no_progress" || tc.reason == "final_attempt"
|
||||
if got != want || r.Reason != tc.reason {
|
||||
t.Fatalf("admit=%t want=%t reason=%s: %+v", got, want, tc.reason, r)
|
||||
}
|
||||
})
|
||||
}
|
||||
r := PrecopyReport{Reason: "samples_unknown", Estimate: time.Second}
|
||||
if r.admitPrecopy(&PrecopyAttempt{Reason: "tail_too_large", Estimate: time.Second}, true) {
|
||||
t.Fatal("unknown samples admitted")
|
||||
}
|
||||
}
|
||||
|
||||
func TestPrecopyFixedWindowUsesAvailableFreshSamples(t *testing.T) {
|
||||
_, _, l, _ := precopyLayer(t, 1024, 0)
|
||||
for _, n := range []int{0, 1, 2} {
|
||||
t.Run(string(rune('0'+n)), func(t *testing.T) {
|
||||
l.precopySamples = nil
|
||||
for i := 0; i < n; i++ {
|
||||
l.precopySamples = append(l.precopySamples, precopySample{at: time.Now(), fixed: time.Duration(i+1) * 100 * time.Millisecond})
|
||||
}
|
||||
r := l.precopyEstimate(0, 0)
|
||||
if n == 0 {
|
||||
if r.Reason != "samples_unknown" {
|
||||
t.Fatalf("zero fresh admitted: %+v", r)
|
||||
}
|
||||
return
|
||||
}
|
||||
if r.Reason != "fit" || r.Fixed != time.Duration(n)*100*time.Millisecond {
|
||||
t.Fatalf("%d fresh refused or wrong maximum: %+v", n, r)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestPrecopyUnknownPreviousCannotClaimProgress(t *testing.T) {
|
||||
for _, reason := range []string{"samples_unknown", "drain_refused", "before_barrier"} {
|
||||
t.Run(reason, func(t *testing.T) {
|
||||
r := PrecopyReport{Estimate: 2 * time.Second, Reason: "tail_too_large"}
|
||||
previous := &PrecopyAttempt{Estimate: 200 * time.Millisecond, Reason: reason}
|
||||
if r.admitPrecopy(previous, false) || r.PreviousEstimate != 0 {
|
||||
t.Fatalf("partial previous admitted no_progress: %+v", r)
|
||||
}
|
||||
if !r.admitPrecopy(previous, true) || r.Reason != "final_attempt" {
|
||||
t.Fatalf("unknown previous blocked independent final admission: %+v", r)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -532,8 +532,19 @@ func precopyAttemptDiagnosticsControl(t *testing.T, slow bool) {
|
||||
t.Fatalf("slow diagnostics control lost its measured fixed cost: report=%+v", r.Precopy)
|
||||
}
|
||||
if r.Precopy.Frozen {
|
||||
if err != nil || len(r.Precopy.Rounds) != 2 || (second.Reason != "fit" && second.Reason != "fixed_cost_over_allowance") || !second.Frozen {
|
||||
t.Fatalf("invalid fit after drain timeout: report=%+v err=%v", r.Precopy, err)
|
||||
// A drain refusal is not a comparable estimate. A cheap second
|
||||
// round fits directly; a slow second round establishes the first known
|
||||
// estimate, so only the third may establish no progress.
|
||||
last := r.Precopy.Rounds[len(r.Precopy.Rounds)-1]
|
||||
if err != nil || !last.Frozen {
|
||||
t.Fatalf("invalid admission after drain timeout: report=%+v err=%v", r.Precopy, err)
|
||||
}
|
||||
if second.Reason == "fit" {
|
||||
if len(r.Precopy.Rounds) != 2 || !second.Frozen {
|
||||
t.Fatalf("first fitting round skipped: %+v", r.Precopy)
|
||||
}
|
||||
} else if len(r.Precopy.Rounds) != 3 || second.Frozen || second.Reason != "tail_too_large" || last.Reason != "no_progress" || last.PreviousEstimate != second.Estimate {
|
||||
t.Fatalf("drain refusal treated as a comparable estimate: %+v", r.Precopy)
|
||||
}
|
||||
} else {
|
||||
assertPrecopyMeasuredRefusal(t, r.Precopy, err)
|
||||
|
||||
@@ -19,17 +19,19 @@ func TestPrecopyFixedCostSmallTailCommitsBySecondAttempt(t *testing.T) {
|
||||
f.beforeCAS = func(*fakeChunkRemote) { time.Sleep(fixed) }
|
||||
// Keep the same known small tail and fixed envelope in each attempt.
|
||||
l.precopySamples = nil
|
||||
for i := 0; i < 3; i++ {
|
||||
for i := 0; i < 5; i++ {
|
||||
l.precopySamples = append(l.precopySamples, precopySample{at: time.Now(), fixed: fixed, parts: PrecopyFixedParts{HeadCAS: fixed}, rate: 20 * float64(ctChunkBytes)})
|
||||
}
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
|
||||
defer cancel()
|
||||
r, err := l.PrecopyDetach(ctx, func() bool { return true })
|
||||
if err != nil || !r.Precopy.Frozen || len(r.Precopy.Rounds) > 2 || r.Precopy.Reason != "fixed_cost_over_allowance" || r.Precopy.Fixed < fixed || r.Precopy.DeclaredWorst < fixed {
|
||||
if err != nil || !r.Precopy.Frozen || len(r.Precopy.Rounds) > 2 || r.Precopy.Reason != "no_progress" || r.Precopy.Fixed < fixed || r.Precopy.DeclaredWorst < fixed {
|
||||
t.Fatalf("fixed cost cannot converge by recopying the same small tail: report=%+v err=%v", r.Precopy, err)
|
||||
}
|
||||
if r.Precopy.FreezeElapsed < fixed || r.Precopy.LatencyGateFailed || time.Duration(r.Stats.CASWriteNs) < fixed {
|
||||
// The synthetic estimate excludes real disk scheduling. An overloaded
|
||||
// checkpoint may exceed it; the product must report that overrun honestly.
|
||||
if r.Precopy.FreezeElapsed < fixed || r.Precopy.LatencyGateFailed != (r.Precopy.FreezeElapsed > r.Precopy.DeclaredFreeze) || time.Duration(r.Stats.CASWriteNs) < fixed {
|
||||
t.Fatalf("final fixed-cost operation was not witnessed within its declaration: %+v", r)
|
||||
}
|
||||
if r.Head.State != ChunkHeadDetached || !bytes.Equal(f.imageOf(t, r.Head)[ctBlockSize:2*ctBlockSize], makeBlock(ctBlockSize, byte(rounds))) {
|
||||
@@ -45,12 +47,12 @@ func TestPrecopyLargeTailStillRefusesFixedCostException(t *testing.T) {
|
||||
rounds++
|
||||
w.write(t, s, 1, byte(rounds))
|
||||
l.precopySamples = nil
|
||||
for i := 0; i < 3; i++ {
|
||||
l.precopySamples = append(l.precopySamples, precopySample{at: time.Now(), fixed: time.Millisecond, rate: float64(ctChunkBytes)})
|
||||
for i := 0; i < 5; i++ {
|
||||
l.precopySamples = append(l.precopySamples, precopySample{at: time.Now(), fixed: time.Millisecond, rate: float64(ctChunkBytes) / 4})
|
||||
}
|
||||
}
|
||||
r, err := l.PrecopyDetach(ctTimeout(t), func() bool { t.Fatal("large tail froze"); return true })
|
||||
if !errors.Is(err, ErrPrecopyNotConverged) || r.Precopy.Frozen || len(r.Precopy.Rounds) != 5 || r.Precopy.Reason != "tail_too_large" {
|
||||
if !errors.Is(err, ErrPrecopyNotConverged) || r.Precopy.Frozen || len(r.Precopy.Rounds) != 5 || r.Precopy.Reason != "freeze_budget_exceeded" {
|
||||
t.Fatalf("large tail was not refused: %+v %v", r.Precopy, err)
|
||||
}
|
||||
if f.stats().head.State != ChunkHeadActive {
|
||||
@@ -74,11 +76,11 @@ func TestPrecopyFixedCommitRuleKeepsProgressAndFreezeBounds(t *testing.T) {
|
||||
known, want bool
|
||||
}{
|
||||
{"first", 100 * time.Millisecond, 1500 * time.Millisecond, 0, true, false},
|
||||
{"improving", 100 * time.Millisecond, 1500 * time.Millisecond, 1600 * time.Millisecond, true, false},
|
||||
{"improving", 100 * time.Millisecond, 1500 * time.Millisecond, 1800 * time.Millisecond, true, false},
|
||||
{"stalled", 100 * time.Millisecond, 1500 * time.Millisecond, 1500 * time.Millisecond, true, true},
|
||||
{"worse-fixed", 100 * time.Millisecond, 1600 * time.Millisecond, 1500 * time.Millisecond, true, true},
|
||||
{"quarter", 300 * time.Millisecond, 1500 * time.Millisecond, 1500 * time.Millisecond, true, true},
|
||||
{"large-tail", 300*time.Millisecond + 1, 1500 * time.Millisecond, 1500 * time.Millisecond, true, false},
|
||||
{"large-tail", 300*time.Millisecond + 1, 1500 * time.Millisecond, 1500 * time.Millisecond, true, true},
|
||||
{"unknown", 0, 1500 * time.Millisecond, 1500 * time.Millisecond, false, false},
|
||||
{"freeze-ceiling", 0, 5*time.Second + 1, 5*time.Second + 1, true, false},
|
||||
{"first-freeze-ceiling", 0, 5*time.Second + 1, 0, true, false},
|
||||
@@ -91,15 +93,15 @@ func TestPrecopyFixedCommitRuleKeepsProgressAndFreezeBounds(t *testing.T) {
|
||||
r := PrecopyReport{Fixed: 1300 * time.Millisecond, TailEstimate: tc.tail, Estimate: tc.estimate, Reason: reason}
|
||||
var previous *PrecopyAttempt
|
||||
if tc.previous > 0 {
|
||||
previous = &PrecopyAttempt{Estimate: tc.previous}
|
||||
previous = &PrecopyAttempt{Reason: "tail_too_large", Estimate: tc.previous}
|
||||
}
|
||||
if got := r.admitPrecopy(previous); got != tc.want {
|
||||
if got := r.admitPrecopy(previous, false); got != tc.want {
|
||||
t.Fatalf("admit=%t report=%+v", got, r)
|
||||
}
|
||||
if tc.known && tc.estimate > 5*time.Second && r.Reason != "fixed_cost_exceeds_freeze_budget" {
|
||||
if tc.known && tc.estimate > 5*time.Second && r.Reason != "freeze_budget_exceeded" {
|
||||
t.Fatalf("mislabelled fixed ceiling: %+v", r)
|
||||
}
|
||||
if tc.want && r.Reason != "fixed_cost_over_allowance" {
|
||||
if tc.want && r.Reason != "no_progress" {
|
||||
t.Fatalf("missing exception reason: %+v", r)
|
||||
}
|
||||
})
|
||||
@@ -109,6 +111,9 @@ func TestPrecopyFixedCommitRuleKeepsProgressAndFreezeBounds(t *testing.T) {
|
||||
func TestPrecopyFixedPartsStayWithLargestObservation(t *testing.T) {
|
||||
_, _, l, _ := precopyLayer(t, 1024, 0)
|
||||
l.precopySamples = nil
|
||||
for i := 0; i < 3; i++ {
|
||||
l.samplePrecopy(chunkCutStats{CASNs: 1}, int64(time.Millisecond))
|
||||
}
|
||||
st := chunkCutStats{CASNs: 1, DrainNs: int64(10 * time.Millisecond), LockWaitNs: int64(30 * time.Millisecond), SyncNs: int64(40 * time.Millisecond), CASWriteNs: int64(50 * time.Millisecond), HeadReadbackNs: int64(60 * time.Millisecond), MapPersistNs: int64(10 * time.Millisecond)}
|
||||
l.samplePrecopy(st, int64(200*time.Millisecond))
|
||||
l.samplePrecopy(chunkCutStats{CASNs: 1, SyncNs: int64(100 * time.Millisecond)}, int64(150*time.Millisecond))
|
||||
@@ -120,7 +125,7 @@ func TestPrecopyFixedPartsStayWithLargestObservation(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPrecopyFixedExceptionFinishUsesDeclaredFreeze(t *testing.T) {
|
||||
r := PrecopyReport{Reason: "fixed_cost_over_allowance", Estimate: 1500 * time.Millisecond, DeclaredFreeze: 1500 * time.Millisecond}
|
||||
r := PrecopyReport{Reason: "no_progress", Estimate: 1500 * time.Millisecond, DeclaredFreeze: 1500 * time.Millisecond}
|
||||
r.Finish(1400*time.Millisecond, 0, false)
|
||||
if r.LatencyGateFailed || r.DeclaredWorst != 1500*time.Millisecond {
|
||||
t.Fatalf("new declaration ignored: %+v", r)
|
||||
|
||||
@@ -240,7 +240,7 @@ stateDiagram-v2
|
||||
| Plain detach | explicit `plain=true` bypasses pre-copy cost admission only after exclusive frontend I/O admission succeeds immediately; busy requests change no frontend/pause/HEAD state. It then uses the ordinary StopIO, final cut and outcome settlement. | `provider_chunk.go` `DetachVolumePlain`; `storage_adapter.go` `stopPlainDetachIfIdle`; `chunk_control.go` `handleChunkDetach` | `INV-CUT-PLAIN-DETACH-001`, `INV-WS-HEAD-BELT-001` |
|
||||
| Pre-copy admission | opt-in: close frontend admission and drain registered operations for at most 100 ms before taking the store barrier; rejected attempts reopen before ordinary uploads | `precopy_admission.go` `BeginPrecopyPause`; `chunk_precopy.go` `PrecopyDetachWithAdmission` | `INV-CUT-PRECOPY-001` |
|
||||
| Quiesce | the capture barrier (`captureMu`) is held exclusively, then `Sync` fixes H; `Recover` and writes hold the barrier shared | `core/storage/chunk_layer.go` `captureLocked`; `core/storage/walstore.go` `WALStore.Recover`, `WALStore.Write` | `INV-CUT-QUIESCED-001`, `INV-CUT-RECOVER-BARRIER-001` |
|
||||
| Pre-copy detach | at most five rolling attempts within a cooperative 60 s context; authoritative candidates and measured costs admit the final cut after the bounded drain; a non-improving tail of at most 25% of allowance may use a declared fixed-cost exception within the existing five-second freeze ceiling; frozen commands wait up to the five-second cutover budget and resume in FIFO order after a safe abort | `chunk_precopy.go`; `precopy_admission.go`; `DurableProvider.DetachVolume` | `INV-CUT-PRECOPY-001` |
|
||||
| Pre-copy detach | at most five rolling attempts within a cooperative 60 s context; authoritative candidates and measured costs admit the final cut after the bounded drain; a known estimate may use the declared five-second freeze ceiling when it is at least 90% of the previous comparable known estimate or on the final physical round; frozen commands wait up to the five-second cutover budget and resume in FIFO order after a safe abort | `chunk_precopy.go`; `precopy_admission.go`; `DurableProvider.DetachVolume` | `INV-CUT-PRECOPY-001` |
|
||||
| Pre-copy host drain | a committed freeze keeps commands held while host storage admission closes; transport teardown cancels held commands before joining the session, without issuing their storage work | `storage_adapter.go` `setOperationalLocked`; `nvme/session.go` `serve` | `INV-CUT-PRECOPY-001` |
|
||||
| Copy | every candidate chunk (native owned LSN map relative to HEAD plus retained WAL/in-memory dirt) is read by a bounded upload worker at upload time; a staged copy is reused only if unchanged since staging; native copy occurs after barrier release with pre-publication COW ownership | `core/storage/chunk_layer.go` `captureLocked` | `INV-CUT-QUIESCED-001`, `INV-CUT-STAGED-REUSE-001`, `INV-CUT-BITMAP-001` |
|
||||
| LSN guard | refuse when H is below HEAD's `RemoteLSN` (`lsn_behind`) | `core/storage/chunk_layer.go` `captureLocked` | `INV-WS-HEAD-MONOTONE-001` |
|
||||
@@ -481,7 +481,7 @@ Notes:
|
||||
| `INV-CUT-COW-OWNER-001` | Before any read-visible native mutation, a pending candidate has one saving owner; copying/saving collisions wait. The immutable cut buffer is exactly the image at H. | M5 OpenWindow → Copy | `chunk_cut_cow.go` `claim`, `beforeCOWMutation`; Write/WriteBatch/applyEntryV3 pre-publication hooks | `TestCutCOWV3_MutationCompletesWhileEarlierChunkCopyIsHeld`, `TestCutCOWV3_CopyingChunkWaitsButPendingChunkSaves`, `TestCutCOWV3_TwoWritersOneSaveAndCloseJoinsSavedReader`, `TestCutCOWV3_OverlappingRealBatchesPreserveCut` | CutCOW2 BufFrozen/HeadImage; writer/batch multiplicity tested, not modelled | ACTIVE |
|
||||
| `INV-CUT-COW-DRAIN-001` | Terminal invalidation forbids new references; aborting owners release themselves before join. Side cleanup and destructive transitions wait for actual I/O references. Store Close cannot miss first attachment; every Close waits for full shutdown. | M5 Closed/Aborted → Drain; M1 Close/Recover | `chunk_cut_cow.go` `abort`, `join`, `holdChunkDestructive`; `WALStore.Close`; attach capture admission | `TestCutCOWV3_RecoveryAndCloseDrainSavingOwner`, `TestCutCOWV3_CloseJoinsHeldLiveCopy`, `TestCutCOWV3_CloseSnapshotRejectsFirstAttachAndSharesCompletion`, `TestCutCOWV3_DestructiveSnapshotRetriesFirstAttachment`, `TestCutCOWV3_SpillIsEphemeralAndCleanupIsPrefixScoped`, `TestCutCOWV3_ProcessCrashDropsSideAndRestoresSyncedImage` | CutCOW2 SideOnlyInCut, abortNoJoin RED; real lifecycle races tested separately | ACTIVE |
|
||||
| `INV-CUT-PLAIN-DETACH-001` | A plain detach closes the frontend only when no I/O holds its admission lock; no store or remote call occurs while this lock is held. An admitted or entering operation makes the request refuse unchanged. Cost admission alone is bypassed; ordinary detached publication and unknown/fenced/aborted settlement stay enforced. An absent or false field preserves pre-copy policy. | M5 Admit -> PlainStop -> Quiesce | `core/frontend/durable/provider_chunk.go` `detachVolume`; `storage_adapter.go` `stopPlainDetachIfIdle`; `core/host/volume/chunk_control.go` | `TestPlainDetachAfterPrecopyRefusalRequiresIdleFrontend`, `TestPlainDetachSkipsPrecopyCostAdmission`, `TestChunkDetachPlainFieldDispatch`, `TestChunkDetachPlainAdapterAndBusyResponse` | `PlainDetach` `IdleAtStop`; physical byte and HEAD controls remain native | ACTIVE |
|
||||
| `INV-CUT-PRECOPY-001` | Opt-in final-tail admission closes frontend admission, drains registered I/O before the store lock within a 100 ms caller context, then uses authoritative barrier candidates and measured costs. Refusal reopens tentative admission before rolling uploads. A contended freeze fallback never replaces an existing pause or its queue clock. Final freeze queues without completion for up to five seconds; safe resume is FIFO, host drain preserves the active queue, and transport teardown cancels commands before joining; no queued storage work is issued. Only settled detached publication permits handoff; aborted rounds retain dirty bytes. Warm attempts and measurement rounds are reported separately, with samples at start; both consume the same five-round budget. Admission fits the allowance or uses a declared fixed-cost exception only when the tail term is at most 25% and the estimate did not improve versus the prior attempt, within five seconds. Disjoint fixed-cost parts come from the same retained sample. | M5 tentative admission -> ordinary COW or FinalFreeze | `chunk_precopy.go`; `precopy_admission.go`; `storage_adapter.go`; `provider_chunk.go` | `TestPrecopyProviderBusyOwnerKeepsServing`, `TestPrecopyProviderBusyOwnerRetryRetainsSlowFixedSample`, `TestPrecopyDetachBusyOwnerExhaustsWithoutStopping`, `TestPrecopyDetachBusyOwnerRetainsSlowFixedCost`, `TestPrecopyDetachRefusedFinalCutKeepsChangedBytes`, `TestPrecopyDetachRefusedFinalCutRetainsSlowFixedCost`, `TestPrecopyDetachRetryResolvesPreviouslyAppliedDetachedCut`, `TestPrecopyDetachAppliedRetryRetainsSlowFixedCost`, `TestPrecopyAttemptDiagnosticsSeparateTimeoutFromFit`, `TestPrecopyAttemptDiagnosticsRetainSlowFixedCost`, `TestPrecopyStopIOReturnTimestampPrecedesFinalPublication`, `TestPrecopyCountsWarmAttemptsSeparatelyFromMeasurementRounds`, `TestPrecopyFixedCostSmallTailCommitsBySecondAttempt`, `TestPrecopyLargeTailStillRefusesFixedCostException`, `TestPrecopyFixedCommitRuleKeepsProgressAndFreezeBounds`, `TestPrecopyFixedPartsStayWithLargestObservation`, `TestPrecopyFixedPartsMeasureCASAndReadbackSeparately`, `TestPrecopyFixedExceptionFinishUsesDeclaredFreeze` (`core/storage/chunk_precopy_fixed_commit_test.go`), `TestPrecopyFiftyIOPSSyncConvergesFirstAttempt` (first eligible allowance or plateau attempt), `TestPrecopyFiftyIOPSSlowMeasuredCostsKeepServing` (retained slow cost, declared admission or refusal, active owner and exact local bytes), `TestPrecopyFiftyIOPSColdCostsKeepAdmissionHonest`, `TestPrecopyFiftyIOPSRoundAccounting` (five total physical rounds, including success and measurement rounds), `TestPrecopyHostDrainDoesNotCompleteHeldGuestIO`, `TestPrecopyTargetCloseDropsHeldCommandWithoutCompletion`, `TestPrecopyDrainLetsAnAdmittedWriterReachTheBarrier`, `TestPrecopyDrainReceives100MillisecondBound`, `TestPrecopyDrainTimeoutReopensWithoutWaitingUnderCapture`, `TestPrecopyLateGateCallerCannotCrossFreeze`, `TestPrecopyQueueResumesInFIFOOrder`, `TestPrecopyStopFallbackPreservesQueuedPause`, `TestPrecopyQueueUsesFiveSecondCutoverBudget`, `TestPrecopyRollingUploadReopensTentativeAdmission`, `TestPrecopyDetachRefusedFinalCutKeepsChangedBytes`, `TestPrecopyDetachSustainedWrapFlushAndFreshRestore` | `PrecopyFixedAdmission.tla` (bounded cost admission only); controlled callers and measured latency are not a model proof | ACTIVE |
|
||||
| `INV-CUT-PRECOPY-001` | Opt-in final-tail admission closes frontend admission, drains registered I/O before the store lock within a 100 ms caller context, then uses authoritative barrier candidates and measured costs. Refusal reopens tentative admission before rolling uploads. A contended freeze fallback never replaces an existing pause or its queue clock. Final freeze queues without completion for up to five seconds; safe resume is FIFO, host drain preserves the active queue, and transport teardown cancels commands before joining; no queued storage work is issued. Only settled detached publication permits handoff; aborted rounds retain dirty bytes. Warm attempts and measurement rounds are reported separately, with samples at start; both consume the same five-round budget. Admission fits the allowance, or declares an estimate within five seconds when it is at least 90% of the previous comparable known estimate, or on the final physical round. The fixed input is the maximum of up to the latest five observations younger than fifteen minutes (at least one required); disjoint parts come from the same selected observation. Unknown samples never admit. | M5 tentative admission -> ordinary COW or FinalFreeze | `chunk_precopy.go`; `precopy_admission.go`; `storage_adapter.go`; `provider_chunk.go` | `TestPrecopyProviderBusyOwnerKeepsServing`, `TestPrecopyProviderBusyOwnerRetryRetainsSlowFixedSample`, `TestPrecopyDetachBusyOwnerExhaustsWithoutStopping`, `TestPrecopyDetachBusyOwnerRetainsSlowFixedCost`, `TestPrecopyDetachRefusedFinalCutKeepsChangedBytes`, `TestPrecopyDetachRefusedFinalCutRetainsSlowFixedCost`, `TestPrecopyDetachRetryResolvesPreviouslyAppliedDetachedCut`, `TestPrecopyDetachAppliedRetryRetainsSlowFixedCost`, `TestPrecopyAttemptDiagnosticsSeparateTimeoutFromFit`, `TestPrecopyAttemptDiagnosticsRetainSlowFixedCost`, `TestPrecopyStopIOReturnTimestampPrecedesFinalPublication`, `TestPrecopyCountsWarmAttemptsSeparatelyFromMeasurementRounds`, `TestPrecopyUnknownPreviousCannotClaimProgress`, `TestPrecopyCallerExpiryVersusClose`, `TestPrecopySmokeTraceAmendment4`, `TestPrecopyFixedWindowDecays`, `TestPrecopyFinalAttemptFreezeCeiling`, `TestPrecopyFixedCostSmallTailCommitsBySecondAttempt`, `TestPrecopyLargeTailStillRefusesFixedCostException`, `TestPrecopyFixedCommitRuleKeepsProgressAndFreezeBounds`, `TestPrecopyFixedPartsStayWithLargestObservation`, `TestPrecopyFixedPartsMeasureCASAndReadbackSeparately`, `TestPrecopyFixedExceptionFinishUsesDeclaredFreeze` (`core/storage/chunk_precopy_fixed_commit_test.go`), `TestPrecopyFiftyIOPSSyncConvergesFirstAttempt` (first eligible allowance or plateau attempt), `TestPrecopyFiftyIOPSSlowMeasuredCostsKeepServing` (retained slow cost, declared admission or refusal, active owner and exact local bytes), `TestPrecopyFiftyIOPSColdCostsKeepAdmissionHonest`, `TestPrecopyFiftyIOPSRoundAccounting` (five total physical rounds, including success and measurement rounds), `TestPrecopyHostDrainDoesNotCompleteHeldGuestIO`, `TestPrecopyTargetCloseDropsHeldCommandWithoutCompletion`, `TestPrecopyDrainLetsAnAdmittedWriterReachTheBarrier`, `TestPrecopyDrainReceives100MillisecondBound`, `TestPrecopyDrainTimeoutReopensWithoutWaitingUnderCapture`, `TestPrecopyLateGateCallerCannotCrossFreeze`, `TestPrecopyQueueResumesInFIFOOrder`, `TestPrecopyStopFallbackPreservesQueuedPause`, `TestPrecopyQueueUsesFiveSecondCutoverBudget`, `TestPrecopyRollingUploadReopensTentativeAdmission`, `TestPrecopyDetachRefusedFinalCutKeepsChangedBytes`, `TestPrecopyDetachSustainedWrapFlushAndFreshRestore` | `PrecopyFixedAdmission.tla` (bounded cost admission only); controlled callers and measured latency are not a model proof | ACTIVE |
|
||||
| `INV-CUT-QUIESCED-001` | HEAD is exactly the image at a quiesced cut H, and H is a synced LSN. | M5 Quiesce → Copy → CAS | `core/storage/chunk_layer.go` `captureLocked` | `TestChunkLayer_C1_HeadIsQuiescedCutImage`, `TestChunkLayer_C3_EveryHeadIsExactUnderConcurrentWrites` (`core/storage/chunk_layer_contract_test.go`) | `CutPipeline` `HeadImage`; `CutCapture` `HeadImage` | ACTIVE |
|
||||
| `INV-CUT-BIRTH-001` | A captured chunk birth is bounded by the same-barrier cut frontier: native capture uses min(conservative owned-map maximum, H), retaining lower inherited births. A dropped unacked suffix and reused LSN cannot emit BirthLSN > HEAD.RemoteLSN; the manifest validator still refuses future births. | M5 Quiesce -> Copy -> Manifest | `core/storage/chunk_birth.go` `captureBirths`; `core/frontend/chunkstore/manifest.go` `PrepareManifest` | `TestChunkBirthDroppedSuffixPublishesWithRealManifest` (`core/storage/chunk_birth_manifest_test.go`), `TestChunkBirthCOWDoesNotObservePostBarrierWrite`, `TestChunkBirthBASEUsesInheritedFrontierIncludingZero` | Cut image at H; real recovery/manifest regression, not a new model claim | ACTIVE |
|
||||
| `INV-CUT-RECONCILING-001` | ARCHIVED: the legacy bitmap/reconciler is retired. Native owned-map validation and fail-closed attach admission replace its dirty-coverage protection; a provided legacy bitmap is ignored. | M5 native map admission | `core/storage/chunk_layer.go` `AttachChunkLayer` | `TestChunkAttachRefusesAnUnmappedNativeStore`; `TestChunkLayerV3_IgnoresProvidedLegacyBitmap` (`core/storage/chunk_layer_map_only_v3_test.go`) | legacy reconciliation transition retired | ARCHIVED |
|
||||
|
||||
@@ -1,38 +1,40 @@
|
||||
----------------------- MODULE PrecopyFixedAdmission -----------------------
|
||||
\* Admission only: data/authority/publication safety is covered by CutCOW2.
|
||||
EXTENDS Integers, TLC
|
||||
CONSTANTS OmitTailGuard, OmitStallGuard, OmitFreezeCap
|
||||
CONSTANTS OmitFinalGuard, OmitStallGuard, OmitFreezeCap, OmitKnownGuard
|
||||
Allowance == 12
|
||||
FreezeLimit == 50
|
||||
Margin == 1
|
||||
VARIABLES fixed, tail, previous, estimate, phase, declared, round
|
||||
vars == <<fixed,tail,previous,estimate,phase,declared,round>>
|
||||
VARIABLES fixed, tail, previous, estimate, phase, declared, round, previousKnown
|
||||
vars == <<fixed,tail,previous,estimate,phase,declared,round,previousKnown>>
|
||||
Init == /\ fixed \in {1,13,60}
|
||||
/\ tail \in {0,1,3,4,20}
|
||||
/\ previous = 0 /\ estimate = fixed + tail + Margin
|
||||
/\ previous = 0 /\ previousKnown = FALSE /\ estimate = fixed + tail + Margin
|
||||
/\ phase = "decide" /\ declared = 0 /\ round = 1
|
||||
Exception == /\ (OmitTailGuard \/ tail <= Allowance \div 4)
|
||||
/\ (OmitStallGuard \/ (previous > 0 /\ estimate >= previous))
|
||||
Plateau == previousKnown /\ previous > 0 /\ 10 * estimate >= 9 * previous
|
||||
UncheckedPlateau == previous > 0 /\ 10 * estimate >= 9 * previous
|
||||
Exception == /\ (OmitStallGuard \/ Plateau \/ (OmitKnownGuard /\ UncheckedPlateau) \/ (~OmitFinalGuard /\ round = 5))
|
||||
/\ (OmitFreezeCap \/ estimate <= FreezeLimit)
|
||||
Eligible == estimate <= Allowance \/ Exception
|
||||
Commit == /\ phase = "decide" /\ Eligible
|
||||
/\ phase' = "committed" /\ declared' = estimate
|
||||
/\ UNCHANGED <<fixed,tail,previous,estimate,round>>
|
||||
/\ UNCHANGED <<fixed,tail,previous,estimate,round,previousKnown>>
|
||||
Copy == /\ phase = "decide" /\ ~Eligible /\ round < 5
|
||||
/\ \E nextTail \in 0..tail:
|
||||
/\ tail' = nextTail /\ previous' = estimate
|
||||
/\ previousKnown' \in BOOLEAN
|
||||
/\ estimate' = fixed + nextTail + Margin
|
||||
/\ round' = round + 1
|
||||
/\ UNCHANGED <<fixed,phase,declared>>
|
||||
Refuse == /\ phase = "decide" /\ ~Eligible /\ round = 5
|
||||
/\ phase' = "refused"
|
||||
/\ UNCHANGED <<fixed,tail,previous,estimate,declared,round>>
|
||||
/\ UNCHANGED <<fixed,tail,previous,estimate,declared,round,previousKnown>>
|
||||
Done == /\ phase # "decide" /\ UNCHANGED vars
|
||||
Next == Commit \/ Copy \/ Refuse \/ Done
|
||||
Spec == Init /\ [][Next]_vars
|
||||
SafeCommit == phase = "committed" =>
|
||||
/\ declared = estimate /\ estimate <= FreezeLimit
|
||||
/\ (estimate > Allowance =>
|
||||
/\ tail <= Allowance \div 4
|
||||
/\ previous > 0 /\ estimate >= previous)
|
||||
(Plateau \/ round = 5))
|
||||
FinalWithinBudget == phase = "refused" => estimate > FreezeLimit
|
||||
=============================================================================
|
||||
@@ -335,33 +335,35 @@ four negative controls separately remove retirement, the frame join, the
|
||||
readiness guard or ACK progress restoration. This abstracts successful admitted
|
||||
frames and does not prove physical-I/O, authority rollback or timing behavior.
|
||||
|
||||
`PrecopyFixedAdmission.tla` checks bounded pre-copy cost admission: ordinary
|
||||
allowance, small non-improving tail, declared freeze and the five-second ceiling.
|
||||
`PrecopyFixedAdmission.cfg` is the positive configuration; `_no_tail`, `_no_stall`
|
||||
and `_no_cap` must violate `SafeCommit`. It does not model publication/data safety
|
||||
or physical latency; those remain separate checks.
|
||||
|
||||
`PrecopyFixedAdmission.tla` checks cost admission over five physical rounds.
|
||||
A known estimate fits the 1.2-second allowance, or uses the five-second declared
|
||||
freeze limit when it is at least 90% of the previous comparable known estimate or on the final
|
||||
round. `SafeCommit` checks the declaration and ceiling; `FinalWithinBudget`
|
||||
checks that an eligible final round cannot refuse. This model does not model
|
||||
sample freshness, current-measurement availability, publication/data safety or physical
|
||||
latency; those remain separate checks.
|
||||
|
||||
### PrecopyFixedAdmission checked configurations
|
||||
|
||||
Recorded local run, 2026-11-20 22:30 UTC, using the v1.7.4 tools distribution (TLC 2.19)
|
||||
(`tla2tools.jar` SHA-256
|
||||
Local amendment-4 review-fold run, 2026-11-21 02:07 UTC, TLC 2.19 (tools jar SHA-256
|
||||
`936a262061c914694dfd669a543be24573c45d5aa0ff20a8b96b23d01e050e88`),
|
||||
from `docs/spec`:
|
||||
|
||||
```sh
|
||||
java -cp /path/to/tla2tools.jar tla2sany.SANY PrecopyFixedAdmission.tla
|
||||
java -cp /path/to/tla2tools.jar tlc2.TLC -deadlock -config cfg/PrecopyFixedAdmission.cfg PrecopyFixedAdmission
|
||||
java -Xmx512m -cp /path/to/tla2tools.jar tlc2.TLC -deadlock -config cfg/PrecopyFixedAdmission.cfg PrecopyFixedAdmission
|
||||
```
|
||||
|
||||
SANY exited 0. The positive configuration exited 0: 11,240 generated states,
|
||||
2,856 distinct, queue empty, complete depth 6. With the same command and the
|
||||
respective `cfg/PrecopyFixedAdmission_no_*.cfg`, each negative exited 12 with
|
||||
`SafeCommit` violated: `no_tail` (266 generated / 262 distinct, depth 3),
|
||||
`no_stall` (44 / 41, depth 2), `no_cap` (546 / 517, depth 3).
|
||||
These are the original local finite-state runs for this model, not a new run
|
||||
for the documentation update. The bounds and exclusions above still apply;
|
||||
this does not establish physical latency, publication safety or train qualification.
|
||||
The positive configuration exited 0: 37,399 generated / 5,851 distinct states,
|
||||
queue empty, depth 6. The same invocation with each negative configuration
|
||||
exited 12: `no_stall` violates `SafeCommit` (24 / 20, depth 2), `no_cap`
|
||||
violates `SafeCommit` (1,634 / 1,024, depth 3), and `no_final` violates
|
||||
`FinalWithinBudget` (34,330 / 4,620, depth 6). The additional
|
||||
`unknown_previous` negative violates `SafeCommit` (640 / 426, depth 3),
|
||||
witnessing that a partial prior estimate cannot establish a plateau. The model
|
||||
tracks previous-known status nondeterministically across rounds; only the
|
||||
current estimate is assumed known. The older quarter-tail model
|
||||
results are superseded by this rule. These finite-state checks do not establish
|
||||
physical latency or train qualification.
|
||||
|
||||
## Plain detach admission
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
OmitTailGuard = FALSE
|
||||
OmitFinalGuard = FALSE
|
||||
OmitStallGuard = FALSE
|
||||
OmitKnownGuard = FALSE
|
||||
OmitFreezeCap = FALSE
|
||||
INVARIANT SafeCommit
|
||||
INVARIANTS SafeCommit FinalWithinBudget
|
||||
@@ -1,6 +1,7 @@
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
OmitTailGuard = FALSE
|
||||
OmitFinalGuard = FALSE
|
||||
OmitStallGuard = FALSE
|
||||
OmitKnownGuard = FALSE
|
||||
OmitFreezeCap = TRUE
|
||||
INVARIANT SafeCommit
|
||||
INVARIANTS SafeCommit FinalWithinBudget
|
||||
@@ -0,0 +1,7 @@
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
OmitFinalGuard = TRUE
|
||||
OmitStallGuard = FALSE
|
||||
OmitKnownGuard = FALSE
|
||||
OmitFreezeCap = FALSE
|
||||
INVARIANTS SafeCommit FinalWithinBudget
|
||||
@@ -1,6 +1,7 @@
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
OmitTailGuard = FALSE
|
||||
OmitFinalGuard = FALSE
|
||||
OmitStallGuard = TRUE
|
||||
OmitKnownGuard = FALSE
|
||||
OmitFreezeCap = FALSE
|
||||
INVARIANT SafeCommit
|
||||
INVARIANTS SafeCommit FinalWithinBudget
|
||||
@@ -1,6 +0,0 @@
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
OmitTailGuard = TRUE
|
||||
OmitStallGuard = FALSE
|
||||
OmitFreezeCap = FALSE
|
||||
INVARIANT SafeCommit
|
||||
@@ -0,0 +1,7 @@
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
OmitFinalGuard = FALSE
|
||||
OmitStallGuard = FALSE
|
||||
OmitKnownGuard = TRUE
|
||||
OmitFreezeCap = FALSE
|
||||
INVARIANTS SafeCommit FinalWithinBudget
|
||||
Reference in new issue
Block a user