Skip to content

Commit

Permalink
[improve][broker] Make timer execute immediately after load index (#2…
Browse files Browse the repository at this point in the history
…0126)

(cherry picked from commit 9b72302)
  • Loading branch information
coderzc authored and poorbarcode committed May 7, 2023
1 parent 88e05b5 commit d08c3cb
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ public long getBufferMemoryUsage() {

@Override
public synchronized NavigableSet<PositionImpl> getScheduledMessages(int maxMessages) {
if (!checkPendingOpDone()) {
if (!checkPendingLoadDone()) {
if (log.isDebugEnabled()) {
log.debug("[{}] Skip getScheduledMessages to wait for bucket snapshot load finish.",
dispatcher.getName());
Expand Down Expand Up @@ -628,11 +628,11 @@ public synchronized NavigableSet<PositionImpl> getScheduledMessages(int maxMessa
if (timeout != null) {
timeout.cancel();
}
timeout = timer.newTimeout(this, tickTimeMillis, TimeUnit.MILLISECONDS);
timeout = timer.newTimeout(this, 0, TimeUnit.MILLISECONDS);
}
});

if (!checkPendingOpDone() || loadFuture.isCompletedExceptionally()) {
if (!checkPendingLoadDone() || loadFuture.isCompletedExceptionally()) {
break;
}
}
Expand All @@ -651,7 +651,7 @@ public synchronized NavigableSet<PositionImpl> getScheduledMessages(int maxMessa
return positions;
}

private synchronized boolean checkPendingOpDone() {
private synchronized boolean checkPendingLoadDone() {
if (pendingLoad == null || pendingLoad.isDone()) {
pendingLoad = null;
return true;
Expand Down

0 comments on commit d08c3cb

Please sign in to comment.