Skip to content

[Go] Fix missing return after retry scheduling in process_queue - #1265

Merged
RongtongJin merged 1 commit into
apache:masterfrom
guyinyou:fix_process_queue
Jun 11, 2026
Merged

RongtongJin merged 1 commit into
apache:masterfrom
guyinyou:fix_process_queue

Conversation

@guyinyou

Copy link
Copy Markdown
Contributor

In ackMessage0, changeInvisibleDuration, and forwardToDeadLetterQueue0, when the response code is not OK, the *Later() retry function is called but execution falls through to callback(nil), causing the message to be prematurely evicted from cache before the operation actually succeeds. This can lead to message loss.

Add return statements after each *Later() call to prevent fallthrough, matching the Java implementation's behavior where the future is only resolved on terminal states (success or abandoned).

In ackMessage0, changeInvisibleDuration, and forwardToDeadLetterQueue0,
when the response code is not OK, the *Later() retry function is called
but execution falls through to callback(nil), causing the message to be
prematurely evicted from cache before the operation actually succeeds.
This can lead to message loss.

Add return statements after each *Later() call to prevent fallthrough,
matching the Java implementation's behavior where the future is only
resolved on terminal states (success or abandoned).

@RongtongJin RongtongJin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One inline review comment from my manual review.

Comment thread golang/process_queue.go
@@ -154,6 +154,7 @@ func (dpq *defaultProcessQueue) forwardToDeadLetterQueue0(mv *MessageView, attem
" clientId=%s, consumerGroup=%s, messageId=%s, attempt=%d, mq=%s, endpoints=%v, requestId=%s, status message=[%s]", clientId, consumerGroup, messageId, attempt, dpq.mqstr,
endpoints, requestId, status.GetMessage())
dpq.forwardToDeadLetterQueueLater(mv, 1+attempt, callback)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This retry path still does not retry forwarding to the DLQ. With the new return, the message is no longer evicted immediately after scheduling, but forwardToDeadLetterQueueLater currently calls ackMessage0 when the timer fires, and its recover path schedules ackMessageLater. If that ACK succeeds, the callback evicts the message even though it never reached the DLQ. Please make forwardToDeadLetterQueueLater re-enter forwardToDeadLetterQueue0, and have the recover path reschedule forwardToDeadLetterQueueLater.

@RongtongJin
RongtongJin merged commit bf4462c into apache:master Jun 11, 2026
14 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants