From fd5a6ff4276155c9c48acd9cb37ed2ac059089cd Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Thu, 9 Jul 2026 00:29:17 -0700 Subject: [PATCH] log_buffer: cap the shared-snapshot race test's heap (#10281) TestSharedSnapshotConcurrentIntegrity writes as fast as one core can marshal for two seconds, so its transient heap scales with host speed. On linux/386 a fast runner walks the heap into the 4GB address-space ceiling and the run dies with out of memory. Set a 1GB memory limit for the duration of the test so the GC paces the writer instead of the address space; the seal-and-recycle race being tested is unaffected. --- weed/util/log_buffer/shared_snapshot_test.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/weed/util/log_buffer/shared_snapshot_test.go b/weed/util/log_buffer/shared_snapshot_test.go index 370f9a82c..35797c9e7 100644 --- a/weed/util/log_buffer/shared_snapshot_test.go +++ b/weed/util/log_buffer/shared_snapshot_test.go @@ -2,6 +2,7 @@ package log_buffer import ( "fmt" + "runtime/debug" "sync" "testing" "time" @@ -85,6 +86,12 @@ func TestSharedSnapshotSurvivesRecycle(t *testing.T) { // and recycling windows. Every delivered entry must unmarshal cleanly with the // expected payload — corruption here means a reader saw recycled bytes. func TestSharedSnapshotConcurrentIntegrity(t *testing.T) { + // The writer below is deliberately unthrottled, so transient marshal garbage + // scales with host speed; on linux/386 a fast runner can hit the 4GB + // address-space ceiling. Cap the heap so the GC paces the writer instead. + prevLimit := debug.SetMemoryLimit(1 << 30) + defer debug.SetMemoryLimit(prevLimit) + lb := NewLogBuffer("test", time.Hour, func(*LogBuffer, time.Time, time.Time, []byte, int64, int64) {}, nil, nil) defer lb.ShutdownLogBuffer()