Fix the race condition in realtime text index refresh thread
@@ -66,7 +66,6 @@ public class RealtimeLuceneIndexReaderRefreshThread implements Runnable {
@Override
public void run() {
while (!_stopped) {
- while (_luceneRealtimeReaders.isEmpty()) {
_mutex.lock();
try {
// During instantiation of a given MutableSegmentImpl, we will signal on this condition variable once
@@ -86,14 +85,15 @@ public class RealtimeLuceneIndexReaderRefreshThread implements Runnable {
// there were few realtime segments of a table with text index. Later if they got
// moved to another server as part of rebalance, then again there is no need for this thread
// to do anything until some realtime segment is created with text index enabled.
+ while (_luceneRealtimeReaders.isEmpty()) {
_conditionVariable.await();
+ }
} catch (InterruptedException e) {
LOGGER.warn("Realtime lucene reader refresh thread got interrupted while waiting on condition variable: ", e);
Thread.currentThread().interrupt();
} finally {
_mutex.unlock();
}
- } // end while
// check if shutdown has been initiated
if (_stopped) {
