Skip to content

Harden hot-to-warm tiering and file registry warm read routing - #22103

Merged
mgodwan merged 3 commits into
opensearch-project:mainfrom
vishwasgarg18:enhacment/warm-tiering-and-search
Jun 17, 2026
Merged

mgodwan merged 3 commits into
opensearch-project:mainfrom
vishwasgarg18:enhacment/warm-tiering-and-search

Conversation

@vishwasgarg18

@vishwasgarg18 vishwasgarg18 commented Jun 10, 2026 •

Copy link
Copy Markdown
Contributor

Description

This change fixes two issues in the writable-warm (hot-to-warm tiering) path:

1. Non-blocking merge drain — fixes a thread-pool deadlock during tiering prepare

The prepare-tiering step used to block a thread (on the MANAGEMENT pool) while
waiting for in-flight merges to drain. Under load this could exhaust the pool and
deadlock, since the merges themselves need threads to complete. This change makes
the prepare path fully non-blocking:

  • TransportBroadcastByNodeAction gains an opt-in async mode (shardOperationAsync)
    that dispatches each shard operation to a thread pool and sends the node response
    only after all shards complete — no thread is held while waiting.
  • The DFA engine/merge scheduler expose a freeze/onDrained model: the prepare
    action freezes the engine (blocking new merges and primary writes), registers a
    merge-drain listener, and completes the flush/refresh/remote-sync on the callback.
    In-flight merges drain to completion; pending merges are not re-registered while frozen.
  • A configurable, dynamic timeout cluster.tiering.prepare_timeout (default 90s) bounds
    the wait. On timeout the shard fails with a typed MergeDrainTimeoutException carrying
    the active/pending merge counts, and the coordinator surfaces targeted, actionable
    error messages.
  • Cancel now also resolves the tiering service from the persisted tiering state, so a
    mid-migration index remains cancellable after a cluster-manager failover.

2. Per-query object-store registry isolation (DataFusion backend)

Each per-query RuntimeEnv now gets its own DefaultObjectStoreRegistry. Previously,
concurrent queries registering different shard stores under the bare file:// scheme
could clobber each other, routing one shard's parquet read through another shard's store
and failing with "No such file or directory."

Related Issues

Resolves #[issue number]

Check List

  • Functionality includes testing.
  • API changes companion pull request created, if applicable.
  • Public documentation issue/PR created, if applicable.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@github-actions

github-actions Bot commented Jun 10, 2026 •

Copy link
Copy Markdown
Contributor

PR Code Analyzer ❗

AI-powered 'Code-Diff-Analyzer' found issues on commit fb74643.

PathLineSeverityDescription
server/src/main/java/org/opensearch/index/shard/IndexShard.java5832highDebug sleep code committed to a production code path: a 30-second Thread.sleep() is unconditionally executed inside syncSegmentsFromRemoteSegmentStore whenever the tiering state is PREPARING or HOT_TO_WARM. The comment explicitly labels this '// DEBUG: Slow down recovery to reproduce merge race during tiering', confirming this is test/debug instrumentation, not intentional production logic. In a live cluster, any index undergoing hot-to-warm tiering will stall recovery for 30 seconds per shard, creating a reliable denial-of-service window during tiering operations. The sleep fires on every recovery invocation for affected indices and swallows the InterruptedException by only re-setting the interrupt flag, preventing clean cancellation.

The table above displays the top 10 most important findings.

Total: 1 | Critical: 0 | High: 1 | Medium: 0 | Low: 0


Pull Requests Author(s): Please update your Pull Request according to the report above.

Repository Maintainer(s): You can bypass diff analyzer by adding label skip-diff-analyzer after reviewing the changes carefully, then re-run failed actions. To re-enable the analyzer, remove the label, then re-run all actions.


⚠️ Note: The Code-Diff-Analyzer helps protect against potentially harmful code patterns. Please ensure you have thoroughly reviewed the changes beforehand.

Thanks.

@vishwasgarg18
vishwasgarg18 force-pushed the enhacment/warm-tiering-and-search branch from 5bca6b5 to 9229260 Compare June 10, 2026 21:58
@github-actions

github-actions Bot commented Jun 10, 2026 •

Copy link
Copy Markdown
Contributor

PR Reviewer Guide 🔍

(Review updated until commit 43f22eb)

Here are some key observations to aid the review process:

🧪 PR contains tests
🔒 No security concerns identified
✅ No TODO sections
🔀 No multiple PR themes
⚡ Recommended focus areas for review

Possible Issue

The findMergeDrainTimeout method walks the cause chain with a bounded depth of 10, but if the chain is deeper or circular, it may miss a MergeDrainTimeoutException or loop indefinitely. While the depth bound prevents infinite loops, a circular chain could still cause the method to examine the same exceptions repeatedly up to the depth limit without detecting the cycle.

private static String findMergeDrainTimeout(Throwable t) {
    int depth = 0;
    while (t != null && depth++ < 10) {
        if (t instanceof MergeDrainTimeoutException) {
            return t.getMessage();
        }
        final String message = t.getMessage();
        if (message != null && message.contains(MergeDrainTimeoutException.MERGE_DRAIN_TIMEOUT_MARKER)) {
            return message;
        }
        t = t.getCause();
    }
    return null;
}
Possible Issue

In the onDrained method, after adding a listener to onDrainedListeners, the double-check attempts to remove and run the listener if merges have drained. However, if the listener is invoked inline here and then the merge thread also fires it (because it was added before the merge thread's snapshot-then-clear), the listener runs twice. The comment acknowledges this race and states listeners must be idempotent, but the code does not enforce idempotency—callers must implement it. If a caller fails to do so, duplicate execution could cause issues like double permit release or double state transitions.

public void onDrained(Runnable listener) {
    if (activeMerges.get() == 0 && !mergeHandler.hasPendingMerges()) {
        listener.run();
        return;
    }
    onDrainedListeners.add(listener);
    // Double-check after adding — merges may have finished between the check and the add
    if (activeMerges.get() == 0 && !mergeHandler.hasPendingMerges()) {
        if (onDrainedListeners.remove(listener)) {
            listener.run();
        }
    }
}
Possible Issue

In onAsyncShardOperation, if threadPool.executor(asyncPool).execute(...) throws (e.g., pool shutdown), the catch block calls shardListener.onFailure(rejection). However, if the pool accepted the task but the task itself throws synchronously inside the lambda (before shardOperationAsync is called), the inner try-catch calls shardListener.onFailure(inner). Both paths invoke the same notifyOnce-wrapped listener, which is correct. But if the pool's execute throws and the task was somehow queued (unlikely but theoretically possible in a race), the listener could be completed twice. The notifyOnce wrapper should prevent double-counting, but the code structure is fragile.

    try {
        threadPool.executor(asyncPool).execute(() -> {
            try {
                shardOperationAsync(request.indicesLevelRequest, shardRouting, shardListener);
            } catch (Exception inner) {
                // shardOperationAsync threw synchronously on the pool worker (e.g. an
                // IndexNotFoundException raced index deletion). Without this, the throw
                // would escape onto the pool's uncaught-exception handler — the listener
                // would never fire, `remaining` would never decrement, and the coordinator
                // would only get a response after its transport timeout. notifyOnce keeps
                // this safe even if the impl partially completed the listener before throwing.
                shardListener.onFailure(inner);
            }
        });
    } catch (Exception e) {
        // Pool rejected at dispatch time (shutdown / saturated) — record as a shard failure
        // on the same (notifyOnce-wrapped) listener so the remaining counter still reaches
        // zero and the node response is sent.
        RejectedExecutionException rejection = new RejectedExecutionException(
            "rejected by thread pool [" + asyncPool + "] for shard " + shardRouting.shardId(),
            e
        );
        shardListener.onFailure(rejection);
    }
}

@github-actions

github-actions Bot commented Jun 10, 2026 •

Copy link
Copy Markdown
Contributor

PR Code Suggestions ✨

Latest suggestions up to 43f22eb

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Validate non-negative merge count

Validate that activeMerges is non-negative to prevent invalid state. Negative merge
counts indicate a logic error and should fail fast rather than propagate corrupted
diagnostic data across the wire.

server/src/main/java/org/opensearch/storage/action/tiering/MergeDrainTimeoutException.java [52-57]

 public MergeDrainTimeoutException(ShardId shardId, int activeMerges, boolean hasPendingMerges, String timeoutValue) {
     super(buildMessage(shardId, activeMerges, hasPendingMerges, timeoutValue));
+    if (activeMerges < 0) {
+        throw new IllegalArgumentException("activeMerges must be non-negative, got: " + activeMerges);
+    }
     setShard(shardId);
     this.activeMerges = activeMerges;
     this.hasPendingMerges = hasPendingMerges;
 }
Suggestion importance[1-10]: 6

__

Why: Adding validation for activeMerges to ensure it's non-negative is a reasonable defensive check that prevents invalid state from propagating. However, this is a minor improvement since the merge count is typically derived from internal counters that should already be non-negative.

Low
Prevent missed drain notifications

The double-check pattern can still miss a drain event if merges complete between the
add and the second check. Consider using a lock or ensuring the finally block in
submitMergeTask checks and fires listeners atomically to prevent missed
notifications.

server/src/main/java/org/opensearch/index/engine/dataformat/merge/MergeScheduler.java [247-259]

 public void onDrained(Runnable listener) {
-    if (activeMerges.get() == 0 && !mergeHandler.hasPendingMerges()) {
-        listener.run();
-        return;
-    }
-    onDrainedListeners.add(listener);
-    if (activeMerges.get() == 0 && !mergeHandler.hasPendingMerges()) {
-        if (onDrainedListeners.remove(listener)) {
+    synchronized (onDrainedListeners) {
+        if (activeMerges.get() == 0 && !mergeHandler.hasPendingMerges()) {
+            listener.run();
+            return;
+        }
+        onDrainedListeners.add(listener);
+        if (activeMerges.get() == 0 && !mergeHandler.hasPendingMerges()) {
+            onDrainedListeners.remove(listener);
             listener.run();
         }
     }
 }
Suggestion importance[1-10]: 3

__

Why: The suggestion identifies a potential race condition in the double-check pattern, but the proposed fix using synchronized on a CopyOnWriteArrayList is not the optimal solution. The existing code already has a race-tolerant design where listeners may fire twice (documented at line 243), and callers are expected to use compareAndSet guards. A better fix would synchronize on a dedicated lock object rather than the list itself, or redesign the coordination between onDrained and the submitMergeTask finally block to be atomic. The score reflects that while the concern is valid, the proposed solution is suboptimal.

Low
General
Handle deep exception chains safely

The depth limit of 10 may be insufficient for deeply nested exception chains.
Consider increasing the limit or using a Set to track visited exceptions to prevent
infinite loops from circular references while allowing deeper traversal.

server/src/main/java/org/opensearch/storage/action/tiering/TransportHotToWarmTierAction.java [310-323]

 private static String findMergeDrainTimeout(Throwable t) {
-    int depth = 0;
-    while (t != null && depth++ < 10) {
+    Set<Throwable> visited = new HashSet<>();
+    while (t != null && visited.add(t)) {
         if (t instanceof MergeDrainTimeoutException) {
             return t.getMessage();
         }
         final String message = t.getMessage();
         if (message != null && message.contains(MergeDrainTimeoutException.MERGE_DRAIN_TIMEOUT_MARKER)) {
             return message;
         }
         t = t.getCause();
     }
     return null;
 }
Suggestion importance[1-10]: 5

__

Why: The suggestion correctly identifies that the depth limit of 10 may be insufficient for deeply nested exception chains and proposes using a Set<Throwable> to prevent infinite loops from circular references. This is a valid improvement that would make the code more robust. However, the impact is moderate since deeply nested exception chains are rare in practice, and the current depth limit of 10 is likely sufficient for most real-world scenarios. The suggestion would require adding import java.util.HashSet; and import java.util.Set; which are already present in the file.

Low
Use enum parsing for state

The method uses .name() on enum constants but compares against a string retrieved
from settings. If the settings store the enum's .toString() instead of .name(), the
comparison will fail. Verify consistency or use enum parsing for robustness.

server/src/main/java/org/opensearch/storage/tiering/TieringService.java [710-716]

 private static boolean isMigrationInProgress(final IndexMetadata indexMetadata) {
     if (indexMetadata == null) {
         return false;
     }
     final String state = indexMetadata.getSettings().get(INDEX_TIERING_STATE.getKey(), IndexModule.TieringState.HOT.name());
-    return IndexModule.TieringState.HOT_TO_WARM.name().equals(state) || IndexModule.TieringState.WARM_TO_HOT.name().equals(state);
+    try {
+        IndexModule.TieringState tieringState = IndexModule.TieringState.valueOf(state);
+        return tieringState == IndexModule.TieringState.HOT_TO_WARM || tieringState == IndexModule.TieringState.WARM_TO_HOT;
+    } catch (IllegalArgumentException e) {
+        return false;
+    }
 }
Suggestion importance[1-10]: 5

__

Why: Using valueOf() for enum parsing is more robust than string comparison and would catch invalid state values. However, the current implementation using .name() and string comparison is consistent with how the settings are stored (as seen in line 714 where IndexModule.TieringState.HOT.name() is used as the default). The suggestion adds robustness but may be unnecessary if the settings always use .name().

Low
Clear pending merges when frozen

When isFrozen is true, the method skips findAndRegisterMerges() but does not clear
pending merges. If the handler is frozen with pending merges, they remain queued
indefinitely. Consider clearing the pending queue or documenting this behavior
explicitly.

server/src/main/java/org/opensearch/index/engine/dataformat/merge/MergeHandler.java [205-211]

 public synchronized void onMergeFinished(OneMerge oneMerge, boolean isFrozen) {
     removeMergingSegments(oneMerge);
     if (isFrozen) {
+        pendingMerges.clear();
         return;
     }
     findAndRegisterMerges();
 }
Suggestion importance[1-10]: 4

__

Why: The suggestion raises a valid concern about pending merges remaining queued when frozen. However, the appropriate behavior depends on the intended semantics of freezing. The suggestion to clear pending merges may be correct, but it could also break expected behavior if pending merges should remain for later processing. This needs verification of the design intent.

Low

Previous suggestions

Suggestions up to commit 7807e26
CategorySuggestion                                                                                                                                    Impact
General
Validate non-negative merge count

Validate that activeMerges is non-negative to prevent invalid state. Negative merge
counts indicate a logic error and should be caught at construction time rather than
silently stored.

server/src/main/java/org/opensearch/storage/action/tiering/MergeDrainTimeoutException.java [52-57]

 public MergeDrainTimeoutException(ShardId shardId, int activeMerges, boolean hasPendingMerges, String timeoutValue) {
     super(buildMessage(shardId, activeMerges, hasPendingMerges, timeoutValue));
+    if (activeMerges < 0) {
+        throw new IllegalArgumentException("activeMerges must be non-negative, got: " + activeMerges);
+    }
     setShard(shardId);
     this.activeMerges = activeMerges;
     this.hasPendingMerges = hasPendingMerges;
 }
Suggestion importance[1-10]: 5

__

Why: Adding validation for activeMerges being non-negative is a reasonable defensive check that could catch logic errors early. However, this is a minor improvement since the value comes from internal merge tracking systems that should already guarantee non-negative counts.

Low
Validate non-null merge parameter

Verify that oneMerge is not null before calling removeMergingSegments to prevent
potential NullPointerException. The method signature doesn't enforce non-null, and
callers might pass null in error scenarios.

server/src/main/java/org/opensearch/index/engine/dataformat/merge/MergeHandler.java [205-211]

 public synchronized void onMergeFinished(OneMerge oneMerge, boolean isFrozen) {
+    if (oneMerge == null) {
+        throw new IllegalArgumentException("oneMerge cannot be null");
+    }
     removeMergingSegments(oneMerge);
     if (isFrozen) {
         return;
     }
     findAndRegisterMerges();
 }
Suggestion importance[1-10]: 4

__

Why: Adding a null check for oneMerge is a reasonable defensive measure. However, this is an internal method called by the merge scheduler, which should never pass null. The validation adds safety but addresses a scenario that shouldn't occur in correct usage.

Low
Prevent potential double-close of permit

The timeout handler and merge-drain callback both close the permit in their finally
blocks. If the timeout fires first and closes the permit, then the merge-drain
callback fires and attempts to close it again, this could cause issues. Consider
wrapping the permit in a reference that can only be closed once, or ensure the
permit implementation is idempotent to double-close.

server/src/main/java/org/opensearch/storage/action/tiering/TransportPrepareTieringAction.java [186-226]

 indexShard.freezeForTiering();
 
 TimeValue mergeTimeout = request.timeout() != null ? request.timeout() : prepareTieringTimeout;
 long mergeTimeoutMillis = (long) (mergeTimeout.millis() * 0.8);
 TimeValue effectiveTimeout = TimeValue.timeValueMillis(mergeTimeoutMillis);
 AtomicBoolean completed = new AtomicBoolean(false);
+AtomicReference<Releasable> permitRef = new AtomicReference<>(permit);
 
 Scheduler.ScheduledCancellable timeout = threadPool.schedule(() -> {
     if (completed.compareAndSet(false, true)) {
         int activeMerges = indexShard.getActiveMergeCount();
         boolean hasPendingMerges = indexShard.hasPendingMerges();
         try {
             listener.onFailure(
                 new MergeDrainTimeoutException(shardRouting.shardId(), activeMerges, hasPendingMerges, mergeTimeout.toString())
             );
         } finally {
-            permit.close();
+            Releasable p = permitRef.getAndSet(null);
+            if (p != null) p.close();
         }
     }
 }, effectiveTimeout, ThreadPool.Names.GENERIC);
 
 indexShard.onMergesDrained(() -> {
     if (completed.compareAndSet(false, true)) {
         timeout.cancel();
         try {
             completeSyncAndFlush(indexShard, shardRouting);
             listener.onResponse(EmptyResult.INSTANCE);
         } catch (Exception e) {
             listener.onFailure(e);
         } finally {
-            permit.close();
+            Releasable p = permitRef.getAndSet(null);
+            if (p != null) p.close();
         }
     }
 });
Suggestion importance[1-10]: 3

__

Why: The suggestion addresses a theoretical double-close scenario, but the AtomicBoolean completed guard already ensures only one path executes the finally block. The Releasable interface in OpenSearch is typically idempotent to double-close, making this change unnecessary defensive programming that adds complexity without clear benefit.

Low
Add null check for settings

Handle the case where getSettings() might return null to prevent potential
NullPointerException. Although unlikely in production, defensive coding prevents
crashes if metadata is malformed.

server/src/main/java/org/opensearch/storage/tiering/TieringService.java [710-716]

 private static boolean isMigrationInProgress(final IndexMetadata indexMetadata) {
-    if (indexMetadata == null) {
+    if (indexMetadata == null || indexMetadata.getSettings() == null) {
         return false;
     }
     final String state = indexMetadata.getSettings().get(INDEX_TIERING_STATE.getKey(), IndexModule.TieringState.HOT.name());
     return IndexModule.TieringState.HOT_TO_WARM.name().equals(state) || IndexModule.TieringState.WARM_TO_HOT.name().equals(state);
 }
Suggestion importance[1-10]: 3

__

Why: While defensive null checking is generally good practice, IndexMetadata.getSettings() is unlikely to return null in the OpenSearch codebase. The existing null check for indexMetadata itself is sufficient for most practical scenarios, making this additional check of marginal value.

Low
Increase exception chain traversal depth

The method walks the cause chain with a bounded depth of 10, but if the chain is
deeper, a merge drain timeout nested beyond that depth will not be detected.
Consider increasing the depth limit or making it configurable to handle deeply
nested exception chains.

server/src/main/java/org/opensearch/storage/action/tiering/TransportHotToWarmTierAction.java [310-323]

 private static String findMergeDrainTimeout(Throwable t) {
     int depth = 0;
-    while (t != null && depth++ < 10) {
+    final int maxDepth = 20;
+    while (t != null && depth++ < maxDepth) {
         if (t instanceof MergeDrainTimeoutException) {
             return t.getMessage();
         }
         final String message = t.getMessage();
         if (message != null && message.contains(MergeDrainTimeoutException.MERGE_DRAIN_TIMEOUT_MARKER)) {
             return message;
         }
         t = t.getCause();
     }
     return null;
 }
Suggestion importance[1-10]: 2

__

Why: While increasing the depth limit from 10 to 20 is harmless, exception chains deeper than 10 levels are extremely rare in practice. The current limit is a reasonable safeguard against infinite loops from circular cause chains, and there is no evidence in the PR or typical OpenSearch usage that deeper traversal is needed.

Low
Suggestions up to commit aaf168a
CategorySuggestion                                                                                                                                    Impact
Possible issue
Use consistent state format

The fallback default value should use .toString() instead of .name() to match the
format used elsewhere in the codebase. The validateIndexCurrentState method uses
.toString() for state comparisons, and inconsistent formats could cause validation
mismatches.

server/src/main/java/org/opensearch/storage/action/tiering/TransportCancelTierAction.java [158-159]

 final String tieringState = indexMetadata.getSettings()
-    .get(IndexModule.INDEX_TIERING_STATE.getKey(), IndexModule.TieringState.HOT.name());
+    .get(IndexModule.INDEX_TIERING_STATE.getKey(), IndexModule.TieringState.HOT.toString());
Suggestion importance[1-10]: 8

__

Why: The suggestion correctly identifies an inconsistency in state format usage. The code uses .name() for the default value while validateIndexCurrentState uses .toString() for comparisons (lines 77-78), which could cause validation mismatches and affect the correctness of tiering state checks.

Medium
Fix race condition in listener firing

The listener firing logic in the finally block has a race condition. Between
List.copyOf and clear(), another thread could add a new listener that gets cleared
without being fired. Use removeAll with the copied list or synchronize the entire
block to ensure atomicity.

server/src/main/java/org/opensearch/index/engine/dataformat/merge/MergeScheduler.java [334-344]

 if (isFrozen() && activeMerges.get() == 0 && !mergeHandler.hasPendingMerges() && !onDrainedListeners.isEmpty()) {
     List<Runnable> listeners = List.copyOf(onDrainedListeners);
-    onDrainedListeners.clear();
+    onDrainedListeners.removeAll(listeners);
     for (Runnable listener : listeners) {
         try {
             listener.run();
         } catch (Exception ex) {
             logger.warn("Exception in onDrained listener", ex);
         }
     }
 }
Suggestion importance[1-10]: 7

__

Why: The suggestion correctly identifies a race condition: between List.copyOf(onDrainedListeners) and onDrainedListeners.clear(), another thread could add a listener that gets cleared without being fired. The proposed fix (removeAll(listeners)) is safer and ensures only the listeners that were copied are removed. This is a real concurrency issue that could lead to lost listener invocations, though the impact is mitigated by the double-check in onDrained (line 257). The fix is straightforward and improves correctness.

Medium
General
Handle InterruptedException appropriately

The catch block catches all exceptions including InterruptedException and
ThreadDeath, which should typically be handled differently or re-thrown. Consider
catching only Exception subtypes that represent operation failures, not thread
interruption or JVM shutdown signals.

server/src/main/java/org/opensearch/action/support/broadcast/node/TransportBroadcastByNodeAction.java [585-591]

 threadPool.executor(asyncPool).execute(() -> {
     try {
         shardOperationAsync(request.indicesLevelRequest, shardRouting, shardListener);
+    } catch (InterruptedException e) {
+        Thread.currentThread().interrupt();
+        shardListener.onFailure(new OpenSearchException("Shard operation interrupted", e));
     } catch (Exception inner) {
         shardListener.onFailure(inner);
     }
-});
Suggestion importance[1-10]: 6

__

Why: The suggestion correctly points out that catching all Exception types (line 587) includes InterruptedException, which should restore the interrupt flag before propagating. However, the catch block is inside a Runnable submitted to the thread pool, so the interrupt flag should be restored but the operation should still fail via shardListener.onFailure. The suggested code does this, making it a valid improvement for proper interrupt handling. The concern about ThreadDeath is less relevant since it extends Error, not Exception, and is not caught here.

Low
Use integer arithmetic for timeout calculation

The timeout calculation uses a floating-point multiplication that could produce
unexpected results for edge cases. Consider using integer arithmetic or adding
validation to ensure the effective timeout is always positive and less than the
original timeout.

server/src/main/java/org/opensearch/storage/action/tiering/TransportPrepareTieringAction.java [346-347]

-long mergeTimeoutMillis = (long) (mergeTimeout.millis() * 0.8);
+long mergeTimeoutMillis = Math.max(1, (mergeTimeout.millis() * 4) / 5);
 TimeValue effectiveTimeout = TimeValue.timeValueMillis(mergeTimeoutMillis);
Suggestion importance[1-10]: 5

__

Why: The suggestion correctly identifies a potential precision issue with floating-point arithmetic, but the impact is minimal since the timeout is in milliseconds and the 0.8 multiplier is exact in binary. The integer alternative (mergeTimeout.millis() * 4) / 5 is cleaner and avoids floating-point entirely, though the Math.max(1, ...) guard is overly cautious (the timeout is already validated to be positive). This is a minor code-quality improvement rather than a bug fix.

Low
Add null check for mergeScheduler

The method delegates to mergeScheduler.onDrained without any null check on
mergeScheduler. If the scheduler is null during engine initialization or shutdown,
this will throw a NullPointerException. Add a null check or document the invariant
that mergeScheduler is never null.

server/src/main/java/org/opensearch/index/engine/DataFormatAwareEngine.java [1389-1392]

 public void onMergesDrained(Runnable listener) {
+    if (mergeScheduler == null) {
+        throw new IllegalStateException("MergeScheduler not initialized");
+    }
     mergeScheduler.onDrained(listener);
 }
Suggestion importance[1-10]: 3

__

Why: The suggestion raises a valid concern about mergeScheduler being null, but the PR code already initializes mergeScheduler in the constructor (line 458) and it is a final field, so it cannot be null after construction. The suggestion's explicit null check would add defensive code for a condition that cannot occur given the class invariants. Documenting the invariant (as the suggestion mentions) would be more appropriate than adding a runtime check.

Low
Suggestions up to commit a16119c
CategorySuggestion                                                                                                                                    Impact
Possible issue
Prevent listener double-fire on exception

The double-check pattern after adding the listener has a subtle race: if the
listener throws an exception during the inline listener.run(), the exception
propagates to the caller but the listener remains in the list. When the merge thread
later fires all listeners in the finally block, it will invoke the same listener
again, potentially causing duplicate side-effects. Wrap the inline invocation in a
try-catch to ensure the listener is always removed from the list even if it throws.

server/src/main/java/org/opensearch/index/engine/dataformat/merge/MergeScheduler.java [247-259]

 public void onDrained(Runnable listener) {
     if (activeMerges.get() == 0 && !mergeHandler.hasPendingMerges()) {
         listener.run();
         return;
     }
     onDrainedListeners.add(listener);
-    // Double-check after adding — merges may have finished between the check and the add
     if (activeMerges.get() == 0 && !mergeHandler.hasPendingMerges()) {
         if (onDrainedListeners.remove(listener)) {
-            listener.run();
+            try {
+                listener.run();
+            } catch (Exception e) {
+                logger.warn("Exception in onDrained listener during double-check", e);
+            }
         }
     }
 }
Suggestion importance[1-10]: 8

__

Why: Excellent catch on a subtle race condition. If the inline listener.run() throws during the double-check path, the listener remains in the list and will be invoked again by the finally block, potentially causing duplicate side-effects. The suggested try-catch ensures the listener is always removed even on exception, preventing double-firing.

Medium
Validate engine state before registering listener

The method delegates to mergeScheduler.onDrained() without any validation that the
engine is in a valid state for registering drain listeners. If the engine is already
closed or the merge scheduler is shut down, the listener may never fire, causing the
caller to hang indefinitely. Add a state check and fail fast if the engine cannot
honor the drain contract.

server/src/main/java/org/opensearch/index/engine/DataFormatAwareEngine.java [1389-1392]

 public void onMergesDrained(Runnable listener) {
+    ensureOpen();
     mergeScheduler.onDrained(listener);
 }
Suggestion importance[1-10]: 7

__

Why: Good catch on a potential issue where registering a drain listener on a closed engine could cause the listener to never fire. Adding ensureOpen() is a standard pattern in the engine code to fail fast when the engine is closed, preventing indefinite hangs.

Medium
General
Extract hardcoded timeout ratio constant

The 0.8 multiplier is hardcoded in two places (here and in
TransportPrepareTieringAction). If this ratio needs adjustment, it must be changed
in both locations. Extract this magic number to a named constant at the class or
package level to ensure consistency and make the timeout strategy explicit.

server/src/main/java/org/opensearch/storage/action/tiering/TransportHotToWarmTierAction.java [346-347]

-long mergeTimeoutMillis = (long) (mergeTimeout.millis() * 0.8);
+private static final double MERGE_TIMEOUT_RATIO = 0.8;
+...
+long mergeTimeoutMillis = (long) (mergeTimeout.millis() * MERGE_TIMEOUT_RATIO);
 TimeValue effectiveTimeout = TimeValue.timeValueMillis(mergeTimeoutMillis);
Suggestion importance[1-10]: 6

__

Why: Valid suggestion to extract the magic number 0.8 into a named constant. This improves maintainability and ensures consistency if the ratio needs adjustment. The suggestion correctly identifies that this value appears in multiple places and should be centralized.

Low
Validate index metadata exists before checking

The validation logic checks both in-memory state and persisted state, but if
indexMetadata is null, isMigrationInProgress returns false silently. This could
allow a cancel request to proceed when the index doesn't exist, leading to
unexpected behavior downstream.

server/src/main/java/org/opensearch/storage/tiering/TieringService.java [693-695]

+if (indexMetadata == null) {
+    throw new IllegalArgumentException("Index [" + index + "] does not exist");
+}
 if (!tieringIndices.contains(index) && !isMigrationInProgress(indexMetadata)) {
     throw new IllegalArgumentException("Index [" + index + "] is not currently undergoing tiering operation");
 }
Suggestion importance[1-10]: 6

__

Why: The suggestion correctly identifies that indexMetadata could be null and proposes explicit validation. However, the isMigrationInProgress method already handles null by returning false (line 711-712), so the current code will throw the "not currently undergoing tiering operation" exception. An explicit null check with a clearer error message would improve diagnostics.

Low
Increase log level for permit failures

The permit acquisition failure path logs at debug level but fails the listener with
the raw IOException. For operational visibility, consider logging at warn or error
level since permit acquisition failures indicate a serious issue (timeout, shard
closing) that warrants immediate attention. The debug level may cause these failures
to be missed in production logs.

server/src/main/java/org/opensearch/storage/action/tiering/TransportPrepareTieringAction.java [175-184]

 Releasable permit;
 try {
     permit = acquirePrimaryPermits(indexShard, shardRouting);
 } catch (IOException e) {
-    logger.debug(
-        () -> "Failed to acquire primary permits for shard [" + shardRouting.shardId() + "] during tiering prepare — will retry",
+    logger.warn(
+        "Failed to acquire primary permits for shard [{}] during tiering prepare — will retry",
+        shardRouting.shardId(),
         e
     );
     listener.onFailure(e);
     return;
 }
Suggestion importance[1-10]: 5

__

Why: The suggestion to increase the log level from debug to warn for permit acquisition failures is reasonable for operational visibility. However, the code already includes retry logic and the debug level may be intentional to avoid log spam during transient failures. The impact is moderate since it's a logging improvement rather than a functional fix.

Low
Distinguish missing tiering state from HOT

The fallback default value HOT.name() may mask a missing tiering state setting.
Consider using null as the default and explicitly checking for null to distinguish
between "explicitly set to HOT" and "setting is absent," which could indicate a
configuration issue.

server/src/main/java/org/opensearch/storage/action/tiering/TransportCancelTierAction.java [158-159]

 final String tieringState = indexMetadata.getSettings()
-    .get(IndexModule.INDEX_TIERING_STATE.getKey(), IndexModule.TieringState.HOT.name());
+    .get(IndexModule.INDEX_TIERING_STATE.getKey());
+if (tieringState == null) {
+    return null;
+}
Suggestion importance[1-10]: 4

__

Why: The suggestion to use null instead of a default value could help distinguish between missing and explicitly set states. However, the current code with a default of HOT.name() is reasonable since HOT is the expected default state for indices. The suggestion's improved code also changes behavior by returning null immediately, which may not be the intended logic flow.

Low
Suggestions up to commit d96aa19
CategorySuggestion                                                                                                                                    Impact
Possible issue
Verify replica operations during freeze

The freeze guard only blocks PRIMARY origin operations, but replica operations are
allowed through. Verify this is intentional: during tiering preparation, replicas
should not receive new writes either (the write block is cluster-wide). If replicas
can still index during freeze, this could lead to inconsistency. Consider blocking
all origins or documenting why replicas are exempt.

server/src/main/java/org/opensearch/index/engine/DataFormatAwareEngine.java [565-567]

-if (isFrozenForTiering() && index.origin() == Engine.Operation.Origin.PRIMARY) {
+// Block all index operations during tiering freeze, not just PRIMARY.
+// Replicas should not receive writes either when the index is write-blocked.
+if (isFrozenForTiering()) {
     throw new IllegalStateException("Engine is frozen for tiering — index operations blocked");
 }
Suggestion importance[1-10]: 7

__

Why: The suggestion raises a valid concern about whether replica operations should also be blocked during freeze. If replicas can still index during freeze, this could lead to inconsistency. However, the PR context suggests this is intentional (replicas use a separate engine), so verification is needed rather than a direct code change.

Medium
General
Guarantee async dispatch off transport thread

The async shard operation is invoked directly on the current thread (the transport
request handler thread). If shardOperationAsync is truly non-blocking (returns
immediately after registering callbacks), this is correct. However, if a subclass's
implementation accidentally blocks or performs heavy computation before returning,
it will still block the transport thread. Consider wrapping the call in a
threadPool.executor(executorName).execute(...) to guarantee the transport thread is
never blocked, even if a subclass misbehaves.

server/src/main/java/org/opensearch/action/support/broadcast/node/TransportBroadcastByNodeAction.java [552-571]

-ActionListener<ShardOperationResult> shardListener = ActionListener.notifyOnce(new ActionListener<ShardOperationResult>() {
-    @Override
-    public void onResponse(ShardOperationResult result) {
-        shardResultOrExceptions[shardIndex] = result;
-        onShardOperationComplete(request, channel, totalShards, shardResultOrExceptions, remaining);
+ActionListener<ShardOperationResult> shardListener = ActionListener.notifyOnce(...);
+threadPool.executor(executor).execute(() -> {
+    try {
+        shardOperationAsync(request.indicesLevelRequest, shardRouting, shardListener);
+    } catch (Exception e) {
+        shardListener.onFailure(e);
     }
-    ...
 });
-shardOperationAsync(request.indicesLevelRequest, shardRouting, shardListener);
Suggestion importance[1-10]: 6

__

Why: The suggestion to wrap shardOperationAsync in a thread pool executor provides additional safety against subclass misbehavior. However, the current implementation assumes shardOperationAsync is non-blocking (as documented), so this is a defensive improvement rather than fixing a known issue.

Low
Extract hardcoded timeout multiplier constant

The timeout calculation uses a hardcoded 0.8 multiplier to reserve 20% buffer before
the transport channel timeout. Consider extracting this magic number as a named
constant (e.g., MERGE_TIMEOUT_BUFFER_RATIO = 0.8) to improve code clarity and
maintainability. This makes the intent explicit and allows easier adjustment if the
buffer ratio needs tuning.

server/src/main/java/org/opensearch/storage/action/tiering/TransportPrepareTieringAction.java [191-192]

-long mergeTimeoutMillis = (long) (mergeTimeout.millis() * 0.8);
+private static final double MERGE_TIMEOUT_BUFFER_RATIO = 0.8;
+
+long mergeTimeoutMillis = (long) (mergeTimeout.millis() * MERGE_TIMEOUT_BUFFER_RATIO);
 TimeValue effectiveTimeout = TimeValue.timeValueMillis(mergeTimeoutMillis);
Suggestion importance[1-10]: 5

__

Why: Extracting the magic number 0.8 as a named constant improves code readability and maintainability. However, this is a minor style improvement with limited impact on functionality.

Low
Document intentional full failure iteration

The loop iterates through all failures to classify them, but continues iterating
even after capturing a sample timeout message. Consider adding an early-exit
optimization: once mergeTimeoutSampleMessage is captured and all remaining failures
are classified, you could break early if only counting is needed. However, since
both counts are required for the final error message logic, the current approach is
correct. No change needed, but document this intentional full iteration.

server/src/main/java/org/opensearch/storage/action/tiering/TransportHotToWarmTierAction.java [191-201]

+// Classify all failures to determine error message strategy.
+// Full iteration required to compute both mergeTimeoutCount and otherFailureCount.
 for (DefaultShardOperationFailedException f : failures) {
     String timeoutMessage = findMergeDrainTimeout(f.getCause());
     if (timeoutMessage != null) {
         mergeTimeoutCount++;
         if (mergeTimeoutSampleMessage == null) {
             mergeTimeoutSampleMessage = timeoutMessage;
         }
     } else {
         otherFailureCount++;
     }
 }
Suggestion importance[1-10]: 3

__

Why: Adding a comment to clarify the intentional full iteration is a minor documentation improvement. The code is already correct, so this suggestion only enhances clarity slightly.

Low
Clarify frozen merge cleanup logic

The early return when isFrozen is true skips findAndRegisterMerges() but still
removes merging segments. This could leave the merge handler in an inconsistent
state if frozen merges should be handled differently. Consider whether
removeMergingSegments() should also be conditional or if frozen merges require
special cleanup logic.

server/src/main/java/org/opensearch/index/engine/dataformat/merge/MergeHandler.java [205-211]

 public synchronized void onMergeFinished(OneMerge oneMerge, boolean isFrozen) {
-    removeMergingSegments(oneMerge);
     if (isFrozen) {
+        removeMergingSegments(oneMerge);
         return;
     }
+    removeMergingSegments(oneMerge);
     findAndRegisterMerges();
 }
Suggestion importance[1-10]: 3

__

Why: The suggestion proposes reordering code for clarity, but the 'improved_code' is functionally identical to the 'existing_code' since removeMergingSegments() is called in both branches. The concern about inconsistent state is not substantiated, as the current logic correctly handles frozen merges by skipping new merge registration.

Low
Suggestions up to commit 4eeff76
CategorySuggestion                                                                                                                                    Impact
General
Extract magic number as constant

The 0.8 multiplier is a magic number without clear justification. Consider
extracting it as a named constant (e.g., MERGE_TIMEOUT_SAFETY_FACTOR = 0.8) with a
comment explaining why 80% of the transport timeout is chosen. This improves
maintainability and makes the timeout calculation self-documenting.

server/src/main/java/org/opensearch/storage/action/tiering/TransportPrepareTieringAction.java [191-192]

-long mergeTimeoutMillis = (long) (mergeTimeout.millis() * 0.8);
+private static final double MERGE_TIMEOUT_SAFETY_FACTOR = 0.8; // Use 80% of transport timeout to fail gracefully before channel timeout
+...
+long mergeTimeoutMillis = (long) (mergeTimeout.millis() * MERGE_TIMEOUT_SAFETY_FACTOR);
 TimeValue effectiveTimeout = TimeValue.timeValueMillis(mergeTimeoutMillis);
Suggestion importance[1-10]: 6

__

Why: The 0.8 multiplier is a magic number that would benefit from being extracted as a named constant with documentation. This improves code maintainability and self-documentation, though the impact is moderate since the calculation is only used once and the context is clear.

Low
Increase minimum timeout threshold

The minimum timeout of 30 seconds may be insufficient for large indices with many
segments during remote store upload. Consider raising the minimum to 60 seconds or
adding validation that warns administrators when the timeout is set below
recommended thresholds for production workloads.

server/src/main/java/org/opensearch/storage/common/tiering/TieringUtils.java [138-144]

 public static final Setting<TimeValue> PREPARE_TIERING_TIMEOUT = Setting.timeSetting(
     PREPARE_TIERING_TIMEOUT_KEY,
     TimeValue.timeValueSeconds(90),
-    TimeValue.timeValueSeconds(30),
+    TimeValue.timeValueSeconds(60),
     Setting.Property.Dynamic,
     Setting.Property.NodeScope
 );
Suggestion importance[1-10]: 5

__

Why: The suggestion to increase the minimum timeout from 30 to 60 seconds is reasonable for production workloads with large indices, but the current 30-second minimum may be intentionally conservative to allow flexibility. The impact is moderate as administrators can already adjust this dynamically.

Low
Profile freeze check performance

The freeze check occurs on every index operation, which could impact hot-path
performance. Consider caching the frozen state more aggressively or using a volatile
read pattern that avoids the method call overhead. Profile this path under load to
ensure the check doesn't become a bottleneck.

server/src/main/java/org/opensearch/index/engine/DataFormatAwareEngine.java [565-567]

+// Consider profiling: if isFrozenForTiering() becomes a hot-path bottleneck,
+// optimize by caching the frozen state or using a more efficient read pattern
 if (isFrozenForTiering() && index.origin() == Engine.Operation.Origin.PRIMARY) {
     throw new IllegalStateException("Engine is frozen for tiering — index operations blocked");
 }
Suggestion importance[1-10]: 4

__

Why: The suggestion to profile the freeze check is reasonable for a hot-path operation. However, isFrozenForTiering() already uses an AtomicBoolean.get() which is a volatile read (very fast), with a fallback settings check only when the flag is false. The performance concern is speculative without evidence of actual bottleneck, making this a lower-priority optimization.

Low
Optimize failure loop iteration

The loop iterates through all failures even after capturing the first sample
message. For large failure arrays, this is inefficient. Consider breaking early once
mergeTimeoutSampleMessage is set and you've counted all merge timeouts, or
restructure to avoid redundant iterations when only a sample is needed.

server/src/main/java/org/opensearch/storage/action/tiering/TransportHotToWarmTierAction.java [191-201]

 for (DefaultShardOperationFailedException f : failures) {
     String timeoutMessage = findMergeDrainTimeout(f.getCause());
     if (timeoutMessage != null) {
         mergeTimeoutCount++;
         if (mergeTimeoutSampleMessage == null) {
             mergeTimeoutSampleMessage = timeoutMessage;
         }
     } else {
         otherFailureCount++;
     }
 }
+// Note: If only sample is needed, consider early break after capturing first timeout
Suggestion importance[1-10]: 3

__

Why: The suggestion to optimize the loop is valid but has limited impact. The loop must iterate through all failures to count both mergeTimeoutCount and otherFailureCount for the error message logic. Early breaking would only save iterations after capturing the sample message, which provides minimal benefit in typical failure scenarios.

Low

@github-actions

Copy link
Copy Markdown
Contributor

❌ Gradle check result for 9229260: null

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@vishwasgarg18 vishwasgarg18 changed the title Harden hot-to-warm tiering and warm read routing Harden hot-to-warm tiering and file registry warm read routing Jun 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Persistent review updated to latest commit 5a1ccf8

@vishwasgarg18
vishwasgarg18 force-pushed the enhacment/warm-tiering-and-search branch from 5a1ccf8 to 392d012 Compare June 11, 2026 11:11
@github-actions

Copy link
Copy Markdown
Contributor

Persistent review updated to latest commit 392d012

@vishwasgarg18
vishwasgarg18 force-pushed the enhacment/warm-tiering-and-search branch from 392d012 to 80dd1e3 Compare June 11, 2026 11:14
@github-actions

Copy link
Copy Markdown
Contributor

Persistent review updated to latest commit 80dd1e3

@github-actions

Copy link
Copy Markdown
Contributor

✅ Gradle check result for 80dd1e3: SUCCESS

@codecov

codecov Bot commented Jun 11, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 57.29537% with 120 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.33%. Comparing base (cca17b8) to head (43f22eb).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...e/action/tiering/TransportHotToWarmTierAction.java 22.72% 51 Missing ⚠️
.../action/tiering/TransportPrepareTieringAction.java 13.04% 40 Missing ⚠️
...in/java/org/opensearch/index/shard/IndexShard.java 42.85% 4 Missing and 4 partials ⚠️
.../index/engine/dataformat/merge/MergeScheduler.java 82.35% 2 Missing and 4 partials ⚠️
...broadcast/node/TransportBroadcastByNodeAction.java 93.47% 3 Missing ⚠️
...ex/engine/DataFormatAwareNRTReplicationEngine.java 0.00% 2 Missing ⚠️
...ch/index/engine/DataFormatAwareReadOnlyEngine.java 0.00% 2 Missing ⚠️
.../main/java/org/opensearch/index/engine/Engine.java 0.00% 2 Missing ⚠️
...torage/common/tiering/TieringServiceValidator.java 0.00% 0 Missing and 2 partials ⚠️
...org/opensearch/storage/tiering/TieringService.java 60.00% 1 Missing and 1 partial ⚠️
... and 2 more
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #22103      +/-   ##
============================================
- Coverage     73.40%   73.33%   -0.08%     
+ Complexity    75872    75856      -16     
============================================
  Files          6068     6068              
  Lines        344623   344852     +229     
  Branches      49584    49622      +38     
============================================
- Hits         252978   252899      -79     
- Misses        71490    71792     +302     
- Partials      20155    20161       +6     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

Copy link
Copy Markdown
Contributor

❌ Gradle check result for e9a1106: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@vishwasgarg18
vishwasgarg18 force-pushed the enhacment/warm-tiering-and-search branch from e9a1106 to ed1da70 Compare June 16, 2026 16:24
@github-actions

Copy link
Copy Markdown
Contributor

Persistent review updated to latest commit ed1da70

@github-actions

Copy link
Copy Markdown
Contributor

❌ Gradle check result for ed1da70: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@vishwasgarg18
vishwasgarg18 force-pushed the enhacment/warm-tiering-and-search branch from ed1da70 to 4eeff76 Compare June 16, 2026 16:32
@github-actions

Copy link
Copy Markdown
Contributor

Persistent review updated to latest commit 4eeff76

@github-actions

Copy link
Copy Markdown
Contributor

❌ Gradle check result for 4eeff76: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@vishwasgarg18
vishwasgarg18 force-pushed the enhacment/warm-tiering-and-search branch from 4eeff76 to d96aa19 Compare June 16, 2026 17:20
@github-actions

Copy link
Copy Markdown
Contributor

Persistent review updated to latest commit d96aa19

@github-actions

Copy link
Copy Markdown
Contributor

❌ Gradle check result for d96aa19: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@vishwasgarg18
vishwasgarg18 force-pushed the enhacment/warm-tiering-and-search branch from d96aa19 to a16119c Compare June 16, 2026 18:58
@github-actions

Copy link
Copy Markdown
Contributor

Persistent review updated to latest commit a16119c

@github-actions

Copy link
Copy Markdown
Contributor

Persistent review updated to latest commit aaf168a

@github-actions

Copy link
Copy Markdown
Contributor

✅ Gradle check result for aaf168a: SUCCESS

    Tiering prepare now freezes the data-format engine and drains
    in-flight merges before the final sync, so no merge mutates the
    catalog after the last refresh. The freeze is driven by
    INDEX_TIERING_STATE (PREPARING/HOT_TO_WARM) on engine open and via
    onSettingsChanged, and explicitly by the prepare action to close the
    cluster-state propagation race. While frozen, primary index, refresh,
    flush, and merge-commit operations are blocked, with bypasses for the
    prepare force-flush and the refresh it drives.

    On prepare failure the index is rolled back out of PREPARING (write
    block removed and tiering state reset to HOT) so the engine unfreezes
    instead of staying stuck and write-blocked. Current-state validation
    accepts PREPARING as a valid starting state for hot-to-warm so the
    second validation pass during prepare succeeds.

Signed-off-by: Vishwas Garg <vishwasgarg14@gmail.com>
Signed-off-by: Vishwas Garg <vishwasgarg14@gmail.com>
@vishwasgarg18
vishwasgarg18 force-pushed the enhacment/warm-tiering-and-search branch from aaf168a to 7807e26 Compare June 17, 2026 08:17
@github-actions

Copy link
Copy Markdown
Contributor

Persistent review updated to latest commit 7807e26

@github-actions

Copy link
Copy Markdown
Contributor

❌ Gradle check result for 7807e26: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

…ndingMergeCount with hasPendingMerges

Signed-off-by: Vishwas Garg <vishwasgarg14@gmail.com>
@vishwasgarg18
vishwasgarg18 force-pushed the enhacment/warm-tiering-and-search branch from 7807e26 to 43f22eb Compare June 17, 2026 08:42
@github-actions

Copy link
Copy Markdown
Contributor

Persistent review updated to latest commit 43f22eb

@github-actions

Copy link
Copy Markdown
Contributor

✅ Gradle check result for 43f22eb: SUCCESS

@mgodwan
mgodwan merged commit f5c42da into opensearch-project:main Jun 17, 2026
15 of 16 checks passed
@andrross

Copy link
Copy Markdown
Member

@vishwasgarg18 @mgodwan A test introduced here is very flaky: #22216

Can we get someone to revert/mute/fix this ASAP?

OVyshnevskyi pushed a commit to OVyshnevskyi/OpenSearch that referenced this pull request Jun 22, 2026
…earch-project#22103)

* Harden hot-to-warm tiering and warm read routing

    Tiering prepare now freezes the data-format engine and drains
    in-flight merges before the final sync, so no merge mutates the
    catalog after the last refresh. The freeze is driven by
    INDEX_TIERING_STATE (PREPARING/HOT_TO_WARM) on engine open and via
    onSettingsChanged, and explicitly by the prepare action to close the
    cluster-state propagation race. While frozen, primary index, refresh,
    flush, and merge-commit operations are blocked, with bypasses for the
    prepare force-flush and the refresh it drives.

    On prepare failure the index is rolled back out of PREPARING (write
    block removed and tiering state reset to HOT) so the engine unfreezes
    instead of staying stuck and write-blocked. Current-state validation
    accepts PREPARING as a valid starting state for hot-to-warm so the
    second validation pass during prepare succeeds.

Signed-off-by: Vishwas Garg <vishwasgarg14@gmail.com>

* Fix unfreeze test

Signed-off-by: Vishwas Garg <vishwasgarg14@gmail.com>

* refactor(tiering): move merge-state methods to Indexer; replace getPendingMergeCount with hasPendingMerges

Signed-off-by: Vishwas Garg <vishwasgarg14@gmail.com>

---------

Signed-off-by: Vishwas Garg <vishwasgarg14@gmail.com>
KhishorekumarBS pushed a commit to KhishorekumarBS/OpenSearch that referenced this pull request Jul 3, 2026
…earch-project#22103)

* Harden hot-to-warm tiering and warm read routing

    Tiering prepare now freezes the data-format engine and drains
    in-flight merges before the final sync, so no merge mutates the
    catalog after the last refresh. The freeze is driven by
    INDEX_TIERING_STATE (PREPARING/HOT_TO_WARM) on engine open and via
    onSettingsChanged, and explicitly by the prepare action to close the
    cluster-state propagation race. While frozen, primary index, refresh,
    flush, and merge-commit operations are blocked, with bypasses for the
    prepare force-flush and the refresh it drives.

    On prepare failure the index is rolled back out of PREPARING (write
    block removed and tiering state reset to HOT) so the engine unfreezes
    instead of staying stuck and write-blocked. Current-state validation
    accepts PREPARING as a valid starting state for hot-to-warm so the
    second validation pass during prepare succeeds.

Signed-off-by: Vishwas Garg <vishwasgarg14@gmail.com>

* Fix unfreeze test

Signed-off-by: Vishwas Garg <vishwasgarg14@gmail.com>

* refactor(tiering): move merge-state methods to Indexer; replace getPendingMergeCount with hasPendingMerges

Signed-off-by: Vishwas Garg <vishwasgarg14@gmail.com>

---------

Signed-off-by: Vishwas Garg <vishwasgarg14@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants