Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.18] Abort pending deletion on IndicesService stop (#123569) #123669

Merged
merged 1 commit into from
Feb 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/changelog/123569.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 123569
summary: Abort pending deletion on `IndicesService` close
area: Store
type: enhancement
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,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;
Expand Down Expand Up @@ -397,6 +398,7 @@ public ClusterService clusterService() {

@Override
protected void doStop() {
stopLatch.countDown();
clusterService.removeApplier(timestampFieldMapperService);
timestampFieldMapperService.doStop();

Expand Down Expand Up @@ -1414,7 +1416,15 @@ public void processPendingDeletes(Index index, IndexSettings indexSettings, Time
}
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);
}
Expand Down