Skip to content

Commit e05b699

Browse files
committed
fix: Track unacked chunked messages to avoid ack holes
1 parent aad6962 commit e05b699

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

lib/ConsumerImpl.cc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,21 @@ optional<SharedBuffer> ConsumerImpl::processMessageChunk(const SharedBuffer& pay
590590
increaseAvailablePermits(cnx);
591591
}
592592
lock.unlock();
593+
// The uncached chunk cannot be assembled into a complete message.
594+
// If the message has expired, acknowledge it directly to avoid ack holes;
595+
// otherwise, track it in the unacked message tracker so it will be redelivered on timeout.
596+
if (expireTimeOfIncompleteChunkedMessageMs_ > 0 &&
597+
TimeUtils::currentTimeMillis() >
598+
static_cast<long>(metadata.publish_time()) + expireTimeOfIncompleteChunkedMessageMs_) {
599+
acknowledgeAsync(messageId, [uuid, messageId](Result result) {
600+
if (result != ResultOk) {
601+
LOG_WARN("Failed to acknowledge uncached chunk, uuid: " << uuid
602+
<< ", messageId: " << messageId);
603+
}
604+
});
605+
} else {
606+
trackMessage(messageId);
607+
}
593608
return {};
594609
}
595610

@@ -656,6 +671,8 @@ optional<SharedBuffer> ConsumerImpl::processMessageChunk(const SharedBuffer& pay
656671
<< ", messageId: " << messageId);
657672
}
658673
});
674+
} else {
675+
trackMessage(messageId);
659676
}
660677
return {};
661678
}

0 commit comments

Comments
 (0)