|
@@ -255,6 +255,7 @@ public class IndicesService extends AbstractLifecycleComponent
|
|
|
private final Map<String, IndexStorePlugin.RecoveryStateFactory> recoveryStateFactories;
|
|
|
private final IndexStorePlugin.IndexFoldersDeletionListener indexFoldersDeletionListeners;
|
|
|
final AbstractRefCounted indicesRefCount; // pkg-private for testing
|
|
|
+ private final CountDownLatch stopLatch = new CountDownLatch(1);
|
|
|
private final CountDownLatch closeLatch = new CountDownLatch(1);
|
|
|
private volatile boolean idFieldDataEnabled;
|
|
|
private volatile boolean allowExpensiveQueries;
|
|
@@ -403,6 +404,7 @@ public class IndicesService extends AbstractLifecycleComponent
|
|
|
|
|
|
@Override
|
|
|
protected void doStop() {
|
|
|
+ stopLatch.countDown();
|
|
|
clusterService.removeApplier(timestampFieldMapperService);
|
|
|
timestampFieldMapperService.doStop();
|
|
|
|
|
@@ -1440,7 +1442,15 @@ public class IndicesService extends AbstractLifecycleComponent
|
|
|
}
|
|
|
if (remove.isEmpty() == false) {
|
|
|
logger.warn("{} still pending deletes present for shards {} - retrying", index, remove.toString());
|
|
|
- Thread.sleep(sleepTime);
|
|
|
+ if (stopLatch.await(sleepTime, TimeUnit.MILLISECONDS)) {
|
|
|
+ logger.info(
|
|
|
+ "Indices service stopped. {} aborting pending deletes after [{}] for shards {}",
|
|
|
+ index,
|
|
|
+ TimeValue.timeValueNanos(System.nanoTime() - startTimeNS),
|
|
|
+ remove.toString()
|
|
|
+ );
|
|
|
+ break;
|
|
|
+ }
|
|
|
sleepTime = Math.min(maxSleepTimeMs, sleepTime * 2); // increase the sleep time gradually
|
|
|
logger.debug("{} schedule pending delete retry after {} ms", index, sleepTime);
|
|
|
}
|