mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 18:47:20 +01:00
storage: preserve internal read waits and replace stale hydration
This commit is contained in:
1 parent
8ff814ac8b
commit
eb177aed83
3 files changed
+13
-12
No files matched your search
@@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
// ErrChunkHydrationPending means no guest bytes were admitted: hydration
|
||||
@@ -13,7 +12,6 @@ var ErrChunkHydrationPending = errors.New("storage: chunk hydration pending")
|
||||
|
||||
const defaultHydrationWorkers = 2
|
||||
const defaultHydrationQueueDepth = 64
|
||||
const defaultHydrationWait = 4 * time.Second
|
||||
|
||||
// ChunkHydrationStats separates wait refusals from owned fetch outcomes.
|
||||
// A wait refusal is not necessarily a wire completion (a caller may cancel).
|
||||
@@ -83,6 +81,11 @@ func (l *chunkLayerImpl) OnReadMissContext(ctx context.Context, lba uint64) ([]b
|
||||
stale := f != nil && (f.gen != gen || f.ref != ref)
|
||||
if stale {
|
||||
f.cancel()
|
||||
// The old worker remains owned and joined, but cannot delay a
|
||||
// new generation or remove its replacement when it finishes.
|
||||
delete(l.hydration, idx)
|
||||
close(f.done)
|
||||
f = nil
|
||||
}
|
||||
if f != nil && !stale {
|
||||
l.stats.Hydration.Joined++
|
||||
@@ -185,6 +188,7 @@ func (l *chunkLayerImpl) hydrationWorker() {
|
||||
}
|
||||
}
|
||||
next.running = true
|
||||
l.stats.Hydration.Active++
|
||||
l.stats.Hydration.Fetches++
|
||||
l.wakeHydrationLocked()
|
||||
l.stMu.Unlock()
|
||||
@@ -201,9 +205,12 @@ func (l *chunkLayerImpl) hydrationWorker() {
|
||||
} else if resolved {
|
||||
l.stats.Hydration.Completed++
|
||||
}
|
||||
l.stats.Hydration.Active--
|
||||
next.err = err
|
||||
delete(l.hydration, next.idx)
|
||||
close(next.done)
|
||||
if l.hydration[next.idx] == next {
|
||||
delete(l.hydration, next.idx)
|
||||
close(next.done)
|
||||
}
|
||||
l.wakeHydrationLocked()
|
||||
l.stMu.Unlock()
|
||||
}
|
||||
|
||||
@@ -547,9 +547,7 @@ func sortedKeys(m map[uint64]bool) []uint64 {
|
||||
// block that has no newer local version, then lets the store read its
|
||||
// extent. It runs with no walstore lock held.
|
||||
func (l *chunkLayerImpl) OnReadMiss(lba uint64) ([]byte, error) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), defaultHydrationWait)
|
||||
defer cancel()
|
||||
return l.OnReadMissContext(ctx, lba)
|
||||
return l.OnReadMissContext(context.Background(), lba)
|
||||
}
|
||||
|
||||
// fillOnce fetches one chunk version and installs every block that has no
|
||||
@@ -1382,9 +1380,7 @@ func (l *chunkLayerImpl) Stats() chunkLayerStats {
|
||||
out.Hydration.WorkerLimit = l.cfg.HydrationWorkers
|
||||
out.Hydration.QueueDepth = l.cfg.HydrationQueueDepth
|
||||
for _, f := range l.hydration {
|
||||
if f.running {
|
||||
out.Hydration.Active++
|
||||
} else {
|
||||
if !f.running {
|
||||
out.Hydration.Queued++
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1049,8 +1049,6 @@ func (s *WALStore) WriteInstrumentation() WriteInstrumentationStatus {
|
||||
func (s *WALStore) Read(lba uint32) ([]byte, error) { return s.ReadContext(context.Background(), lba) }
|
||||
|
||||
func (s *WALStore) ReadContext(ctx context.Context, lba uint32) (data []byte, err error) {
|
||||
ctx, cancel := context.WithTimeout(ctx, defaultHydrationWait)
|
||||
defer cancel()
|
||||
defer func() {
|
||||
if err == nil && ctx.Err() != nil {
|
||||
data = nil
|
||||
|
||||
Reference in new issue
Block a user