From 341cd6ff8621edf0a6bdb77f7fed69c24b673e14 Mon Sep 17 00:00:00 2001 From: Tyler Rockwood Date: Tue, 7 Jan 2025 15:14:37 +0000 Subject: [PATCH] aws/sqs: handle duplicate recieves of inflight stuff --- internal/impl/aws/input_sqs.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/internal/impl/aws/input_sqs.go b/internal/impl/aws/input_sqs.go index 7293f73ed..aa5e48672 100644 --- a/internal/impl/aws/input_sqs.go +++ b/internal/impl/aws/input_sqs.go @@ -297,8 +297,15 @@ func (t *sqsInFlightTracker) AddNew(ctx context.Context, messages ...sqsMessage) if m.handle == nil { continue } - e := t.fifo.PushBack(m.handle) - t.handles[m.handle.id] = e + // If this is a duplicate (a re-recieve of an inflight message due to timeout) + // we can just update the existing handle. + if e, ok := t.handles[m.handle.id]; ok { + e.Value = m.handle + t.fifo.MoveToBack(e) + } else { + e := t.fifo.PushBack(m.handle) + t.handles[m.handle.id] = e + } } }