mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 18:17:16 +01:00
fix(storage): classify ceiling refusals and measure recovery read-backs
This commit is contained in:
1 parent
345b4f685e
commit
fdbac0f463
3 files changed
+26
-10
No files matched your search
@@ -663,6 +663,12 @@ func (l *chunkLayerImpl) captureLocked(ctx context.Context, detach bool) (res ch
|
||||
l.persistCapturedMapV3(versions)
|
||||
st.MapPersistNs += time.Since(start).Nanoseconds()
|
||||
}
|
||||
readCapturedHead := func() (chunkHead, error) {
|
||||
start := time.Now()
|
||||
head, err := readChunkHead(ctx, l.remote)
|
||||
st.HeadReadbackNs += time.Since(start).Nanoseconds()
|
||||
return head, err
|
||||
}
|
||||
var pauseStart time.Time
|
||||
var payloadBeforeBarrier int64
|
||||
defer func() {
|
||||
@@ -1000,7 +1006,7 @@ func (l *chunkLayerImpl) captureLocked(ctx context.Context, detach bool) (res ch
|
||||
if !upgrade && !detach && len(changed) == 0 && h == baseHead.RemoteLSN && baseHead.Gen != 0 && !chunkHeadIsDetached(baseHead) {
|
||||
// A no-op cut still observes authority: a fresh host may have
|
||||
// claimed HEAD without uploading a single chunk since our last cut.
|
||||
cur, err := readChunkHead(ctx, l.remote)
|
||||
cur, err := readCapturedHead()
|
||||
if err != nil {
|
||||
l.abortCut(all)
|
||||
l.dropIntents(ctx, intents)
|
||||
@@ -1066,7 +1072,7 @@ func (l *chunkLayerImpl) captureLocked(ctx context.Context, detach bool) (res ch
|
||||
l.fencePublication(chunkHead{}) // confirmChunkHead already logged the observed root.
|
||||
return chunkCutResult{}, casErr
|
||||
}
|
||||
cur, gerr := readChunkHead(ctx, l.remote)
|
||||
cur, gerr := readCapturedHead()
|
||||
if gerr != nil {
|
||||
keepPending()
|
||||
return chunkCutResult{}, fmt.Errorf("storage: capture CAS outcome unresolved (%v): %w: %w", casErr, errChunkCASOutcomeUnknown, gerr)
|
||||
|
||||
@@ -337,18 +337,21 @@ func (r *PrecopyReport) admitPrecopy(previous *PrecopyAttempt) bool {
|
||||
if r.Reason == "fit" && r.Estimate <= precopyAllowance {
|
||||
return true
|
||||
}
|
||||
if previous == nil || previous.Estimate <= 0 || r.Reason == "samples_unknown" {
|
||||
if r.Reason == "samples_unknown" {
|
||||
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 previous == nil || previous.Estimate <= 0 {
|
||||
return false
|
||||
}
|
||||
r.PreviousEstimate = previous.Estimate
|
||||
if r.TailEstimate > precopyAllowance/4 || r.Estimate < previous.Estimate {
|
||||
return false
|
||||
}
|
||||
// Preserve the frontend's existing five-second held-command ceiling.
|
||||
if r.Estimate > precopyFreezeLimit {
|
||||
r.Reason = "fixed_cost_exceeds_freeze_budget"
|
||||
return false
|
||||
}
|
||||
r.Reason = "fixed_cost_over_allowance"
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -11,15 +11,15 @@ import (
|
||||
func TestPrecopyFixedCostSmallTailCommitsBySecondAttempt(t *testing.T) {
|
||||
s, f, l, w := precopyLayer(t, 1024, 0)
|
||||
fixed := 1300 * time.Millisecond
|
||||
f.beforeCAS = func(*fakeChunkRemote) { time.Sleep(fixed) }
|
||||
rounds := 0
|
||||
l.testBeforeBarrierLockHook = func() {
|
||||
rounds++
|
||||
w.write(t, s, 1, byte(rounds))
|
||||
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++ {
|
||||
l.precopySamples = append(l.precopySamples, precopySample{at: time.Now(), fixed: fixed, rate: 20 * float64(ctChunkBytes)})
|
||||
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)
|
||||
@@ -28,6 +28,9 @@ func TestPrecopyFixedCostSmallTailCommitsBySecondAttempt(t *testing.T) {
|
||||
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 {
|
||||
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 {
|
||||
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))) {
|
||||
t.Fatal("amended commit lost the exact point")
|
||||
}
|
||||
@@ -77,6 +80,7 @@ func TestPrecopyFixedCommitRuleKeepsProgressAndFreezeBounds(t *testing.T) {
|
||||
{"large-tail", 300*time.Millisecond + 1, 1500 * time.Millisecond, 1500 * time.Millisecond, true, false},
|
||||
{"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},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
reason := "tail_too_large"
|
||||
@@ -91,6 +95,9 @@ func TestPrecopyFixedCommitRuleKeepsProgressAndFreezeBounds(t *testing.T) {
|
||||
if got := r.admitPrecopy(previous); 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" {
|
||||
t.Fatalf("mislabelled fixed ceiling: %+v", r)
|
||||
}
|
||||
if tc.want && r.Reason != "fixed_cost_over_allowance" {
|
||||
t.Fatalf("missing exception reason: %+v", r)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user