mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-10-29 00:10:42 +01:00
fix(mount): bound reader cache memory across open files (#11220)
* fix(filer): bound retained reader cache buffers by bytes * test(filer): keep in-flight downloads during cache trimming * feat(mem): expose pooled allocation capacity for byte reservations * fix(mount): share a configurable reader buffer budget across files * fix(filer): release failed prefetch slots and memory reservations * feat(mount): expose a soft Go runtime memory limit * docs(filer): restore shared-download rationale in startCaching The one-line comment replacing the original context.Background() explanation was too thin for readChunkAt to cross-reference shared resource semantics. Restore a concise note on why request cancellation must not abort a download shared by concurrent readers. * test(filer): loosen reader cache test deadlines to 5s Three tests used 1-second deadlines that can flake on CI under load: TestReaderCacheBudgetInFlight, TestReaderCacheEvictionDoesNotHoldCacheLock, and TestReaderCacheFailedPrefetchReleasesBudget. Increase to 5 seconds. * test(filer): cover re-read after reader cache eviction Add TestReaderCacheReReadAfterEviction: reads chunk 'a', reads chunk 'b' (evicting 'a' via budget pressure), then re-reads 'a' and asserts a fresh download returns correct data. Verifies the core correctness property that eviction never exposes missing or stale data to readers.
This commit is contained in:
1 parent
c6b330be2b
commit
4a1d65939f
13 files changed
+497
-31
No files matched your search
@@ -0,0 +1,39 @@
|
||||
//go:build linux || darwin || freebsd || windows
|
||||
|
||||
package command
|
||||
|
||||
import (
|
||||
"math"
|
||||
"runtime/debug"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestConfigureMountMemory(t *testing.T) {
|
||||
for _, size := range []int64{-1, 0, 1, 256, math.MaxInt64 >> 20, math.MaxInt64} {
|
||||
err := configureMountMemory(&MountOptions{readerCacheSizeMB: &size})
|
||||
valid := size > 0 && size <= math.MaxInt64>>20
|
||||
if (err == nil) != valid {
|
||||
t.Errorf("size=%d: err=%v", size, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestConfigureMountMemoryRuntimeLimit(t *testing.T) {
|
||||
previous := debug.SetMemoryLimit(512 << 20)
|
||||
defer debug.SetMemoryLimit(previous)
|
||||
for _, size := range []int64{0, -1, math.MaxInt64, 768, 0} {
|
||||
before := debug.SetMemoryLimit(-1)
|
||||
err := configureMountMemory(&MountOptions{memoryLimitMB: &size})
|
||||
valid := size >= 0 && size <= math.MaxInt64>>20
|
||||
if (err == nil) != valid {
|
||||
t.Errorf("size=%d: err=%v", size, err)
|
||||
}
|
||||
want := before
|
||||
if valid && size > 0 {
|
||||
want = size << 20
|
||||
}
|
||||
if got := debug.SetMemoryLimit(-1); got != want {
|
||||
t.Errorf("size=%d: runtime limit=%d, want %d", size, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user