Skip to content

[DiskThresholdMonitor] Add cluster.blocks.read.auto_release setting - #22610

Open
nagendramohan wants to merge 1 commit into
opensearch-project:mainfrom
nagendramohan:fix/disk-threshold-read-block-auto-release-20539
Open

[DiskThresholdMonitor] Add cluster.blocks.read.auto_release setting#22610
nagendramohan wants to merge 1 commit into
opensearch-project:mainfrom
nagendramohan:fix/disk-threshold-read-block-auto-release-20539

Conversation

@nagendramohan

Copy link
Copy Markdown

Description

The DiskThresholdMonitor unconditionally auto-releases index.blocks.read on all indices, even when manually set by users. This introduces a new dynamic cluster setting cluster.blocks.read.auto_release (default: true) that controls whether
read blocks are automatically released.

Setting it to false allows operators to prevent automatic release of manually-set read blocks.

Design note: When auto_release=false, system-set blocks (warm node file cache) are also not released automatically. This is intentional — the setting gives operators full manual control over all read blocks. Operators who disable auto-release
accept responsibility for managing all blocks, including system-set ones. This mirrors the behavior of the existing cluster.blocks.create_index.auto_release setting.

Related Issues

Resolves #20539

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.

… unconditional auto-release of user-set index read blocks

The DiskThresholdMonitor unconditionally auto-releases index.blocks.read
on all indices, even when manually set by users. This introduces a new
dynamic cluster setting cluster.blocks.read.auto_release (default: true)
that controls whether read blocks are automatically released. Setting it
to false allows operators to prevent automatic release of manually-set
read blocks.

Resolves opensearch-project#20539

Signed-off-by: Nagendra Mohan <nagendramohan1990@gmail.com>
@nagendramohan
nagendramohan requested a review from a team as a code owner July 30, 2026 10:15
@github-actions github-actions Bot added bug Something isn't working good first issue Good for newcomers Search Search query, autocomplete ...etc labels Jul 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🧪 PR contains tests
🔒 No security concerns identified
✅ No TODO sections
🔀 No multiple PR themes
⚡ No major issues detected

@github-actions

Copy link
Copy Markdown
Contributor

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Ensure listener completion when release disabled

When auto-release is disabled but indicesToBlockRead is also empty, handleReadBlocks
may not invoke the listener at all (depending on the outer flow shown in the elided
else branch). Ensure that when indicesToReleaseReadBlock is empty, the listener is
still completed via the existing else branch so the outer
GroupedActionListener/countdown does not stall.

server/src/main/java/org/opensearch/cluster/routing/allocation/DiskThresholdMonitor.java [497-509]

 private void handleReadBlocks(ClusterState state, Set<String> indicesToBlockRead, ActionListener<Void> listener) {
     final Set<String> indicesToReleaseReadBlock;
     if (diskThresholdSettings.isIndexReadBlockAutoReleaseEnabled()) {
         indicesToReleaseReadBlock = StreamSupport.stream(
             Spliterators.spliterator(state.routingTable().indicesRouting().entrySet(), 0),
             false
         )
             .map(Map.Entry::getKey)
             .filter(index -> indicesToBlockRead.contains(index) == false)
             .filter(index -> state.getBlocks().hasIndexBlock(index, IndexMetadata.INDEX_READ_BLOCK))
             .collect(Collectors.toSet());
     } else {
-        indicesToReleaseReadBlock = Set.of();
+        indicesToReleaseReadBlock = Collections.emptySet();
     }
Suggestion importance[1-10]: 2

__

Why: The suggestion's stated concern about listener completion is not addressed by the trivial change from Set.of() to Collections.emptySet()—both are empty sets and behave identically. The existing else branch (visible at line 513) already handles the empty case, so the concern appears unfounded.

Low

@github-actions

Copy link
Copy Markdown
Contributor

❌ Gradle check result for 3dd7d77: 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?

@nagendramohan

Copy link
Copy Markdown
Author

Gradle check failure is unrelated to this change. The failing test RestoreShallowSnapshotV2IT.testHashedPrefixTranslogMetadataCombination timed out (suite timeout exceeded >= 1200000 msec) — this is a remote store snapshot integration test with no relation to DiskThresholdSettings or DiskThresholdMonitor. Requesting re-run.https://build.ci.opensearch.org/job/gradle-check/82795/console

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working good first issue Good for newcomers Search Search query, autocomplete ...etc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] DiskThresholdMonitor unconditionally auto-releases user-set index.blocks.read setting

1 participant