Source:
<code>public void run() { try { int entryCount; ScanResults currentScanResults = scanResults.get(); if (isScanning || currentScanResults == null) { return; } else { entryCount = queueEntryCount.get(); } long processStartTimeMs = time.milliseconds(); <START> for (int i = 0; i < entryCount && !cancelled; i++) { <END> EntryContext entryContext = recentEntryQueue.poll(); if (entryContext == null) { throw new IllegalStateException( String.format("Invalid queue state in store %s. Expected entryCount %d, current index: %d", storeId, entryCount, i)); } metrics.statsRecentEntryQueueSize.update(queueEntryCount.decrementAndGet()); StoreKey key = entryContext.key; IndexValue newValue = entryContext.currentValue; IndexValue originalPut = entryContext.originalPutValue; IndexValue previousValue = entryContext.previousValue; if (newValue.getOffset().compareTo(currentScanResults.scannedEndOffset) >= 0) { if (newValue.isDelete()) { processNewDelete(currentScanResults, key, newValue, originalPut, previousValue); } else if (newValue.isUndelete()) { processNewUndelete(currentScanResults, key, newValue, originalPut, previousValue); } else if (newValue.isTtlUpdate()) { processNewTtlUpdate(currentScanResults, newValue, originalPut); } else { processNewPut(currentScanResults, newValue); } } } metrics.statsRecentEntryQueueProcessTimeMs.update(time.milliseconds() - processStartTimeMs, TimeUnit.MILLISECONDS); } catch (Exception e) { logger.error("Unexpected exception while running QueueProcessor in store {}", storeId, e); metrics.blobStoreStatsQueueProcessorErrorCount.inc(); } }</code><technical_language>I if worthwhile add additional check in this "for" statement. is, checking if is IndexScanner is ongoing. for (int i = 0; i < entryCount && !cancelled && !isScanning; i++) QueueProcessor starts IndexScanner. IndexScanner while QueueProcessor is ongoing</technical_language>

Target:
public void run() { try { int entryCount; ScanResults currentScanResults = scanResults.get(); if (isScanning || currentScanResults == null) { return; } else { entryCount = queueEntryCount.get(); } long processStartTimeMs = time.milliseconds(); for (int i = 0; i < entryCount && !cancelled && !isScanning; i++) { EntryContext entryContext = recentEntryQueue.poll(); if (entryContext == null) { throw new IllegalStateException( String.format("Invalid queue state in store %s. Expected entryCount %d, current index: %d", storeId, entryCount, i)); } metrics.statsRecentEntryQueueSize.update(queueEntryCount.decrementAndGet()); StoreKey key = entryContext.key; IndexValue newValue = entryContext.currentValue; IndexValue originalPut = entryContext.originalPutValue; IndexValue previousValue = entryContext.previousValue; if (newValue.getOffset().compareTo(currentScanResults.scannedEndOffset) >= 0) { if (newValue.isDelete()) { processNewDelete(currentScanResults, key, newValue, originalPut, previousValue); } else if (newValue.isUndelete()) { processNewUndelete(currentScanResults, key, newValue, originalPut, previousValue); } else if (newValue.isTtlUpdate()) { processNewTtlUpdate(currentScanResults, newValue, originalPut); } else { processNewPut(currentScanResults, newValue); } } } metrics.statsRecentEntryQueueProcessTimeMs.update(time.milliseconds() - processStartTimeMs, TimeUnit.MILLISECONDS); } catch (Exception e) { logger.error("Unexpected exception while running QueueProcessor in store {}", storeId, e); metrics.blobStoreStatsQueueProcessorErrorCount.inc(); } }