From f28c32fa11e9a2c290c4291e4bdd866281abecb1 Mon Sep 17 00:00:00 2001 From: zhangzhibiao Date: Sun, 8 Mar 2026 18:45:18 +0800 Subject: [PATCH] fix Flaky test: ReaderSeekTest.testHasMessageAvailableAfterSeekToEnd --- lib/ConsumerImpl.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/ConsumerImpl.cc b/lib/ConsumerImpl.cc index 757b6e84..c728352d 100644 --- a/lib/ConsumerImpl.cc +++ b/lib/ConsumerImpl.cc @@ -1804,7 +1804,13 @@ void ConsumerImpl::seekAsyncInternal(long requestId, const SharedBuffer& seek, c if (result == ResultOk) { LockGuard lock(mutex_); if (getCnx().expired() || reconnectionPending_) { - // It's during reconnection, complete the seek future after connection is established + // It's during reconnection, complete the seek future after connection is established. + // Clear local state now so hasMessageAvailable() does not see stale prefetched messages. + ackGroupingTrackerPtr_->flushAndClean(); + incomingMessages_.clear(); + if (lastSeekArg_.has_value() && std::holds_alternative(lastSeekArg_.value())) { + startMessageId_ = std::get(lastSeekArg_.value()); + } seekStatus_ = SeekStatus::COMPLETED; LOG_INFO(getName() << "Delay the seek future until the reconnection is done"); } else {