Skip to content

Add cluster.blocks.read.auto_release setting#20633

Open
drtootsie wants to merge 1 commit intoopensearch-project:mainfrom
drtootsie:add-read-block-auto-release-setting
Open

Add cluster.blocks.read.auto_release setting#20633
drtootsie wants to merge 1 commit intoopensearch-project:mainfrom
drtootsie:add-read-block-auto-release-setting

Conversation

@drtootsie
Copy link

Addresses #20539

Problem

DiskThresholdMonitor unconditionally auto-releases index.blocks.read on all indices, even when manually set by users. This setting was added to support warm node file cache threshold protection, but the implementation assumes index.blocks.read is only used by the system.

Unlike cluster.blocks.create_index which has cluster.blocks.create_index.auto_release to control this behavior, there is no equivalent setting for index.blocks.read.

Solution

Add cluster.blocks.read.auto_release setting to control read block auto-release behavior, following the same pattern as cluster.blocks.create_index.auto_release.

Changes

+ public static final Setting<Boolean> CLUSTER_READ_BLOCK_AUTO_RELEASE = Setting.boolSetting(
+     "cluster.blocks.read.auto_release",
+     true,
+     Setting.Property.Dynamic,
+     Setting.Property.NodeScope
+ );

+ private volatile boolean readBlockAutoReleaseEnabled;

+ public boolean isReadBlockAutoReleaseEnabled() {
+     return readBlockAutoReleaseEnabled;
+ }

In DiskThresholdMonitor.handleReadBlocks():

+ if (diskThresholdSettings.isReadBlockAutoReleaseEnabled()) {
      indicesToReleaseReadBlock = StreamSupport.stream(...)
          .filter(index -> indicesToBlockRead.contains(index) == false)
          .filter(index -> state.getBlocks().hasIndexBlock(index, IndexMetadata.INDEX_READ_BLOCK))
          .collect(Collectors.toSet());
+ } else {
+     indicesToReleaseReadBlock = Set.of();
+ }

Usage

Users can disable auto-release to preserve manually-set read blocks:

PUT /_cluster/settings
{
  "persistent": {
    "cluster.blocks.read.auto_release": false
  }
}

Testing

  • Set index.blocks.read: true manually on an index
  • With default setting (true): block is auto-released
  • With cluster.blocks.read.auto_release: false: block persists
  • Warm node file cache protection still works (sets blocks that get auto-released)

Impact

  • Default behavior unchanged (auto-release enabled)
  • Users can now control read block auto-release
  • Manually-set read blocks can persist until explicitly removed

@drtootsie drtootsie requested a review from a team as a code owner February 15, 2026 20:15
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 15, 2026

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR adds conditional auto-release functionality for read-blocks in disk threshold management. It introduces a new dynamic cluster setting that gates automatic read-block release logic, allowing operators to control whether blocked indices are automatically unblocked when disk conditions improve.

Changes

Cohort / File(s) Summary
Read-Block Auto-Release Configuration
server/src/main/java/org/opensearch/cluster/routing/allocation/DiskThresholdSettings.java
Introduces new cluster setting CLUSTER_READ_BLOCK_AUTO_RELEASE (boolean, dynamic, node-scoped) with corresponding volatile field, getter, and settings update listener for dynamic updates.
Read-Block Release Logic
server/src/main/java/org/opensearch/cluster/routing/allocation/DiskThresholdMonitor.java
Adds conditional branching in handleReadBlocks() that computes indicesToReleaseReadBlock based on the isReadBlockAutoReleaseEnabled() flag; when disabled, release set is empty, otherwise computed as currently blocked indices not in the block-list that retain INDEX_READ_BLOCK.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~18 minutes

🚥 Pre-merge checks | ✅ 3 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and concisely summarizes the main change: adding a new cluster setting to control read block auto-release behavior.
Description check ✅ Passed The description includes all required sections: Problem statement, Solution, Changes with code examples, Usage instructions, and Testing details. It comprehensively addresses the issue and follows the template structure.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
server/src/main/java/org/opensearch/cluster/routing/allocation/DiskThresholdMonitor.java (1)

496-527: ⚠️ Potential issue | 🟠 Major

Apply indicesNotToAutoRelease filter to indicesToReleaseReadBlock in handleReadBlocks.

The read-only block auto-release in handleReadOnlyBlocks (line 456) filters out indicesNotToAutoRelease to prevent releasing blocks on flood-stage, high-watermark, or nodes with missing usage data. However, handleReadBlocks does not apply this same filter to indicesToReleaseReadBlock, allowing read blocks to be auto-released on indices that should remain blocked. This creates an asymmetry where read-only blocks are protected but read blocks are not.

Pass indicesNotToAutoRelease to handleReadBlocks and apply the same filter to indicesToReleaseReadBlock (around line 499-506) to match the pattern in handleReadOnlyBlocks.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8c244c0 and 10ce8c8.

📒 Files selected for processing (2)
  • server/src/main/java/org/opensearch/cluster/routing/allocation/DiskThresholdMonitor.java
  • server/src/main/java/org/opensearch/cluster/routing/allocation/DiskThresholdSettings.java
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2026-01-13T17:40:27.167Z
Learnt from: reta
Repo: opensearch-project/OpenSearch PR: 20411
File: server/src/main/java/org/opensearch/index/codec/CodecService.java:112-133
Timestamp: 2026-01-13T17:40:27.167Z
Learning: Avoid capturing or evaluating a supplier (e.g., this::defaultCodec) upfront when passing it to a registry during object construction. If registries may replace defaults during iteration (as in EnginePlugin.getAdditionalCodecs), pass the supplier itself and only resolve it at use time. This ensures dynamic behavior is preserved during initialization and prevents premature binding of defaults in codecs/registry setup. This pattern should apply to similar initialization paths in Java server code where registries may mutate defaults during construction.

Applied to files:

  • server/src/main/java/org/opensearch/cluster/routing/allocation/DiskThresholdMonitor.java
  • server/src/main/java/org/opensearch/cluster/routing/allocation/DiskThresholdSettings.java
🔇 Additional comments (2)
server/src/main/java/org/opensearch/cluster/routing/allocation/DiskThresholdSettings.java (1)

117-122: Clean, consistent addition mirroring the existing createIndexBlockAutoReleaseEnabled pattern.

Setting definition, volatile field, constructor init, update consumer registration, setter, and getter all follow the established convention. LGTM.

Also applies to: 132-132, 163-163, 175-175, 377-379, 439-441

server/src/main/java/org/opensearch/cluster/routing/allocation/DiskThresholdMonitor.java (1)

497-509: Correct conditional gating of read-block auto-release.

The toggle cleanly wraps the existing release computation and falls back to an immutable empty set when disabled. This is consistent with how isCreateIndexBlockAutoReleaseEnabled() gates the create-index block release in handleClusterCreateIndexBlocks.

@github-actions
Copy link
Contributor

❌ Gradle check result for 10ce8c8: 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?

Addresses opensearch-project#20539

DiskThresholdMonitor unconditionally auto-releases index.blocks.read
on all indices, even when manually set by users. This was designed for
warm node file cache threshold protection but affects all nodes.

Changes:
- Add CLUSTER_READ_BLOCK_AUTO_RELEASE setting (default: true)
- Check isReadBlockAutoReleaseEnabled() before auto-releasing read blocks
- Follows same pattern as CLUSTER_CREATE_INDEX_BLOCK_AUTO_RELEASE

Users can now disable auto-release:
PUT /_cluster/settings
{
  "persistent": {
    "cluster.blocks.read.auto_release": false
  }
}

This allows manually-set read blocks to persist until explicitly removed.

Signed-off-by: Pepper Pancoast <ppancoast@ntst.com>
@drtootsie drtootsie force-pushed the add-read-block-auto-release-setting branch from 10ce8c8 to a493f8b Compare February 15, 2026 20:27
@github-actions
Copy link
Contributor

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

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.

1 participant