Skip to content

Commit

Permalink
KYLIN-4771 Clear the recordCachePool when the deadline has reached;ad…
Browse files Browse the repository at this point in the history
…d timeout for the recordCachePool offer method.
  • Loading branch information
ggKe authored and hit-lacus committed Oct 18, 2020
1 parent 8c81806 commit 6096f08
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public boolean hasNext() {
if (System.currentTimeMillis() > deadline) {
masterThread.interrupt(); // notify main thread
cancelFlag.set(true);
recordCachePool.clear();
logger.warn("Beyond the deadline for {}.", queryId);
throw new RuntimeException("Timeout when iterate search result");
}
Expand All @@ -112,6 +113,7 @@ public Record next() {
if (one == null) {
masterThread.interrupt(); // notify main thread
cancelFlag.set(true);
recordCachePool.clear();
logger.debug("Exceeded the deadline for {}.", queryId);
throw new RuntimeException("Timeout when iterate search result");
}
Expand Down Expand Up @@ -141,10 +143,15 @@ public ResultIterateWorker(IStreamingSearchResult result) {

@Override
public void run() {
long offserTimeout = 0L;
try {
result.startRead();
for (Record record : result) {
recordCachePool.put(record.copy());
offserTimeout = deadline - System.currentTimeMillis();
if (!recordCachePool.offer(record, offserTimeout, TimeUnit.MILLISECONDS)) {
logger.warn("Timeout when offer to recordCachePool, deadline: {}, offser Timeout: {}", deadline, offserTimeout);
break;
}
}
result.endRead();
} catch (InterruptedException inter) {
Expand Down

0 comments on commit 6096f08

Please sign in to comment.