mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-09-20 05:20:49 +02:00
Stop the filer test helpers from pinning gigabytes of log buffers (#10560)
* log buffer: wake the interval loop on shutdown instead of sleeping through it loopInterval parked in time.Sleep(flushInterval) and only re-checked IsStopping when it woke, so a buffer shut down early kept both loop goroutines - and the PreviousBufferCount+1 slabs of BufferSize they reach - alive for up to a full interval afterwards. Select on shutdownCh against a ticker instead, and give the loops a WaitGroup so a test can observe that they exit. * test: release the filers the server tests build Every helper here left its filer's meta log buffer running, so each test pinned PreviousBufferCount+1 buffers of BufferSize for the rest of the run: ~3.5GB of live heap across the package, which overruns the address space on linux/386 and kills the 32-bit job with an out-of-memory throw. Thread the test through the helpers so the buffer is shut down on cleanup, and shut the subscribe harness's filer down outright - its deletion loop keeps the whole filer reachable otherwise. That harness quiesces its flush path first, since Filer.Shutdown closes the store a flush still in flight would write through.
This commit is contained in:
@@ -576,3 +576,24 @@ func TestLoopProcessLogDataWithOffset_DiskReadRetry(t *testing.T) {
|
||||
t.Logf("✓ SUCCESS: Message received after %d disk read attempts", finalDiskReadCount)
|
||||
}
|
||||
}
|
||||
|
||||
// A buffer shut down long before its flush interval elapses must not keep its
|
||||
// loops - and the tens of megabytes of slabs they reach - alive until the next
|
||||
// tick would have fired.
|
||||
func TestShutdownStopsGoroutinesPromptly(t *testing.T) {
|
||||
lb := NewLogBuffer("shutdown", time.Hour, nil, nil, nil)
|
||||
// let both loops start and park in their waits before shutting down
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
lb.ShutdownLogBuffer()
|
||||
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
lb.loopsDone.Wait()
|
||||
close(done)
|
||||
}()
|
||||
select {
|
||||
case <-done:
|
||||
case <-time.After(5 * time.Second):
|
||||
t.Fatal("log buffer goroutines still running 5s after shutdown")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user