mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 18:17:16 +01:00
storage: scope freeze costs and resolve applied detach retries
This commit is contained in:
1 parent
88cfcdd939
commit
973e27e988
2 files changed
+21
-6
No files matched your search
@@ -807,11 +807,16 @@ func (l *chunkLayerImpl) captureLocked(ctx context.Context, detach bool) (res ch
|
||||
defer done()
|
||||
start := time.Now()
|
||||
var st chunkCutStats
|
||||
var pauseStart time.Time
|
||||
var payloadBeforeBarrier int64
|
||||
defer func() {
|
||||
st.TotalNs = time.Since(start).Nanoseconds()
|
||||
if err == nil {
|
||||
res.Stats = st
|
||||
l.samplePrecopy(st)
|
||||
if !pauseStart.IsZero() {
|
||||
fixed := time.Since(pauseStart).Nanoseconds() - st.PayloadNs + payloadBeforeBarrier
|
||||
l.samplePrecopy(st, fixed)
|
||||
}
|
||||
}
|
||||
if errors.Is(err, errChunkLayerFenced) {
|
||||
l.stMu.Lock()
|
||||
@@ -898,7 +903,8 @@ func (l *chunkLayerImpl) captureLocked(ctx context.Context, detach bool) (res ch
|
||||
// writer blocks new readers of captureMu, so a write arriving while the cut
|
||||
// waits for writers already holding it (e.g. parked in WAL admission) is
|
||||
// paused too. LockWaitNs reports that wait on its own.
|
||||
pauseStart := time.Now()
|
||||
payloadBeforeBarrier = st.PayloadNs
|
||||
pauseStart = time.Now()
|
||||
if hook := l.testBeforeBarrierLockHook; hook != nil {
|
||||
hook()
|
||||
}
|
||||
|
||||
@@ -119,6 +119,14 @@ func (l *chunkLayerImpl) PrecopyDetach(ctx context.Context, stopIO func() bool)
|
||||
r, err := l.captureLocked(ctx, false)
|
||||
report.TentativePauseTotal, report.LongestTentativePause = pauseTotal, longestPause
|
||||
r.Precopy = report
|
||||
if errors.Is(err, errChunkLayerDetached) {
|
||||
if previous, ok := l.storedDetach(); ok {
|
||||
previous.Precopy = report
|
||||
previous.Precopy.Frozen = true
|
||||
previous.Precopy.Reason = "previous_detach_applied"
|
||||
return previous, nil
|
||||
}
|
||||
}
|
||||
if report.Frozen {
|
||||
attempts := countCAS() - casAtFreeze
|
||||
extra := uint64(0)
|
||||
@@ -155,8 +163,9 @@ func (l *chunkLayerImpl) precopyEstimate(tail uint64, attempts int) PrecopyRepor
|
||||
r.SampleAge = age
|
||||
}
|
||||
// With at most 32 observations the maximum is a conservative empirical
|
||||
// p99 envelope of the measured non-payload path (including final
|
||||
// metadata, CAS/read-back and settlement). The stop is already drained.
|
||||
// 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
|
||||
}
|
||||
@@ -194,8 +203,8 @@ func (l *chunkLayerImpl) precopyEstimate(tail uint64, attempts int) PrecopyRepor
|
||||
return r
|
||||
}
|
||||
|
||||
func (l *chunkLayerImpl) samplePrecopy(st chunkCutStats) {
|
||||
s := precopySample{at: time.Now(), fixed: time.Duration(max(int64(1), st.TotalNs-st.PayloadNs))}
|
||||
func (l *chunkLayerImpl) samplePrecopy(st chunkCutStats, fixedNs int64) {
|
||||
s := precopySample{at: time.Now(), fixed: time.Duration(max(int64(1), fixedNs))}
|
||||
if st.UploadedBytes > 0 && st.PayloadNs > 0 {
|
||||
s.rate = float64(st.UploadedBytes) / time.Duration(st.PayloadNs).Seconds()
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user