From 515b905011c123a978d4ecae951fa501441bcd70 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Wed, 2 Dec 2026 23:47:50 -0800 Subject: [PATCH] s3notification: lose the test lock on the fetch of the records' partition (#13324) TestALeadThatLostItsLockDoesNotSend dropped the forwarder lock on the first fetch of any partition, then waited for a fetch of partition 0. When another partition's goroutine fetched first, the lead stopped before partition 0 was fetched and the wait timed out (seen on the 32-bit job). The hook now gets the request and drops the lock on partition 0's fetch. Co-authored-by: Claude Opus 5.5 --- weed/s3api/s3notification/forwarder_test.go | 9 ++++++--- weed/s3api/s3notification/publisher_test.go | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/weed/s3api/s3notification/forwarder_test.go b/weed/s3api/s3notification/forwarder_test.go index b96d65230b..abb0661446 100644 --- a/weed/s3api/s3notification/forwarder_test.go +++ b/weed/s3api/s3notification/forwarder_test.go @@ -148,7 +148,7 @@ func (b *fakeBroker) FetchMessage(ctx context.Context, req *mq_pb.FetchMessageRe hook := b.onFetch b.mu.Unlock() if hook != nil { - hook() + hook(req) } b.mu.Lock() defer b.mu.Unlock() @@ -1235,8 +1235,11 @@ func TestALeadThatLostItsLockDoesNotSend(t *testing.T) { s.broker.appendRecords("a", "b") var once sync.Once s.broker.mu.Lock() - s.broker.onFetch = func() { - once.Do(func() { s.locks.holder(ForwarderLockPrefix + "lost").held.Store(false) }) + s.broker.onFetch = func(req *mq_pb.FetchMessageRequest) { + // another partition can fetch first, so lose the lock on the records' one + if req.Partition.RangeStart == 0 { + once.Do(func() { s.locks.holder(ForwarderLockPrefix + "lost").held.Store(false) }) + } } s.broker.mu.Unlock() s.forwarder(t, "gw1").Sync(s.registry(t, "lost")) diff --git a/weed/s3api/s3notification/publisher_test.go b/weed/s3api/s3notification/publisher_test.go index 6e72eb2dc5..3b0f3c775b 100644 --- a/weed/s3api/s3notification/publisher_test.go +++ b/weed/s3api/s3notification/publisher_test.go @@ -507,7 +507,7 @@ type fakeBroker struct { holding bool holdAt int64 // onFetch runs as a fetch arrives - onFetch func() + onFetch func(req *mq_pb.FetchMessageRequest) // fetchErrorCode, when set, answers every fetch with that broker error, as a broker that cannot read the files does fetchErrorCode int32 }