diff --git a/server/src/main/java/org/opensearch/index/IndexSettings.java b/server/src/main/java/org/opensearch/index/IndexSettings.java index bfeed81bbda1c..c8403eb8c3727 100644 --- a/server/src/main/java/org/opensearch/index/IndexSettings.java +++ b/server/src/main/java/org/opensearch/index/IndexSettings.java @@ -1115,7 +1115,7 @@ public IndexSettings(final IndexMetadata indexMetadata, final Settings nodeSetti INDEX_DOC_ID_FUZZY_SET_FALSE_POSITIVE_PROBABILITY_SETTING, this::setDocIdFuzzySetFalsePositiveProbability ); - scopedSettings.addSettingsUpdateConsumer(INDEX_MAX_UNCOMMITTED_TRANSLOG_FILES,this::setMaxUncommittedTranslogFiles); + scopedSettings.addSettingsUpdateConsumer(INDEX_MAX_UNCOMMITTED_TRANSLOG_FILES, this::setMaxUncommittedTranslogFiles); } private void setMaxUncommittedTranslogFiles(int maxUncommittedTranslogFiles) { diff --git a/server/src/main/java/org/opensearch/index/shard/IndexShard.java b/server/src/main/java/org/opensearch/index/shard/IndexShard.java index e869f658edae0..1cd0c49b58876 100644 --- a/server/src/main/java/org/opensearch/index/shard/IndexShard.java +++ b/server/src/main/java/org/opensearch/index/shard/IndexShard.java @@ -4457,7 +4457,7 @@ public Durability getTranslogDurability() { * threshold count determined by {@code index.translog.max_uncommitted_files_threshold} * @return {@code true} if the shard should be Refreshed */ - boolean shouldRefreshShard(){ + boolean shouldRefreshShard() { final Engine engine = getEngineOrNull(); if (engine != null) { try { @@ -4471,17 +4471,11 @@ boolean shouldRefreshShard(){ private final AtomicBoolean isRefreshRunning = new AtomicBoolean(); - /** - * Will Call a blocking Refresh and then Trim the Unreferenced Translog files - */ - private void refreshAndTrimTranslogfiles(String source) throws IOException { - refresh(source); - getEngine().translogManager().trimUnreferencedTranslogFiles(); - } - /** * Schedules a flush or translog generation roll if needed but will not schedule more than one concurrently. The operation will be * executed asynchronously on the flush thread pool. + * Also Schedules a refresh if Number of Translog files breaches the threshold count determined by + * {@code index.translog.max_uncommitted_files_threshold} */ public void afterWriteOperation() { if (shouldPeriodicallyFlush() || shouldRollTranslogGeneration()) { @@ -4547,7 +4541,7 @@ public void onAfter() { if (shouldRefreshShard()) { logger.info("submitting async Refresh request"); - final AbstractRunnable refreshAndTrimTranslog = new AbstractRunnable() { + final AbstractRunnable _refresh = new AbstractRunnable() { @Override public void onFailure(Exception e) { logger.warn("forced refresh failed after number of uncommited translog files breached limit", e); @@ -4555,7 +4549,7 @@ public void onFailure(Exception e) { @Override protected void doRun() throws Exception { - refreshAndTrimTranslogfiles("Too many uncommited Translog files"); + refresh("Too many uncommited Translog files"); } @Override @@ -4568,7 +4562,7 @@ public void onAfter() { isRefreshRunning.compareAndSet(true, false); } }; - threadPool.executor(ThreadPool.Names.REFRESH).execute(refreshAndTrimTranslog); + threadPool.executor(ThreadPool.Names.REFRESH).execute(_refresh); } else { isRefreshRunning.compareAndSet(true, false); }