diff --git a/server/src/internalClusterTest/java/org/opensearch/gateway/remote/RemoteClusterStateCleanupManagerIT.java b/server/src/internalClusterTest/java/org/opensearch/gateway/remote/RemoteClusterStateCleanupManagerIT.java index 56c8fb94eed91..e96dedaa3e6a0 100644 --- a/server/src/internalClusterTest/java/org/opensearch/gateway/remote/RemoteClusterStateCleanupManagerIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/gateway/remote/RemoteClusterStateCleanupManagerIT.java @@ -129,6 +129,15 @@ public void testRemoteCleanupDeleteStale() throws Exception { manifestFiles >= RETAINED_MANIFESTS && manifestFiles < RETAINED_MANIFESTS + 2 * SKIP_CLEANUP_STATE_CHANGES ); }, 500, TimeUnit.MILLISECONDS); + + // disable the clean up to avoid race condition during shutdown + response = client().admin() + .cluster() + .prepareUpdateSettings() + .setPersistentSettings(Settings.builder().put(REMOTE_CLUSTER_STATE_CLEANUP_INTERVAL_SETTING.getKey(), "-1")) + .get(); + + assertTrue(response.isAcknowledged()); } private void updateClusterStateNTimes(int n) { diff --git a/server/src/main/java/org/opensearch/common/util/concurrent/AbstractAsyncTask.java b/server/src/main/java/org/opensearch/common/util/concurrent/AbstractAsyncTask.java index 0b9dc6136ce60..55441271d8575 100644 --- a/server/src/main/java/org/opensearch/common/util/concurrent/AbstractAsyncTask.java +++ b/server/src/main/java/org/opensearch/common/util/concurrent/AbstractAsyncTask.java @@ -107,23 +107,7 @@ public synchronized void rescheduleIfNecessary() { if (logger.isTraceEnabled()) { logger.trace("scheduling {} every {}", toString(), interval); } - try { - cancellable = threadPool.schedule(this, interval, getThreadPool()); - } catch (OpenSearchRejectedExecutionException e) { - if (e.isExecutorShutdown()) { - logger.debug( - new ParameterizedMessage( - "could not schedule execution of [{}] after [{}] on [{}] as executor is shut down", - this, - interval, - getThreadPool() - ), - e - ); - } else { - throw e; - } - } + cancellable = threadPool.schedule(this, interval, getThreadPool()); isScheduledOrRunning = true; } else { logger.trace("scheduled {} disabled", toString());