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 {