Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supporting automatic release of index blocks. Closes #39334 #40338

Conversation

alex101101
Copy link
Contributor

@alex101101 alex101101 commented Mar 22, 2019

Automatically remove INDEX_READ_ONLY_ALLOW_DELETE_BLOCK block on index once node(s) disk usage at least 5% below the flood_stage watermark and below the high watermark. Feature disabled by default. Closes #39334

@DaveCTurner DaveCTurner added >enhancement :Distributed Coordination/Allocation All issues relating to the decision making around placing a shard (both master logic & on the nodes) v8.0.0 v7.2.0 labels Mar 22, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-distributed

@alex101101 alex101101 force-pushed the automatic-release-of-index-blocks branch from 0abf7b2 to 906dbe9 Compare March 22, 2019 09:06
@DaveCTurner DaveCTurner self-requested a review April 26, 2019 11:49
Copy link
Contributor

@DaveCTurner DaveCTurner left a comment

Choose a reason for hiding this comment

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

Thanks @alex101101. My main concern with this implementation is that it might release the block if a node that's above the flood stage threshold failed to respond to the stats request sent by the InternalClusterInfoService, because then it wouldn't be included in the disk usage statistics. I think it'd be better to only release this block if we are certain that every assigned shard is definitely on a node below the threshold.

I left a few more comments on the implementation, but I haven't been through the tests in detail yet.

nodes that it is sharded across are both 5% above the flood stage watermark
and above the high watermark.

`cluster.routing.allocation.disk.auto_release_index_enabled`::
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that we should move towards making this the default behaviour. I cannot really think of a case where the current behaviour is preferable. We may want to introduce a system property for the 7.x series just in case this counts as a breaking change, similar to this code in 6.7:

static {
final String property = System.getProperty("es.cluster_state.size");
if (property == null) {
CLUSTER_STATE_SIZE = false;
} else {
final boolean clusterStateSize = Boolean.parseBoolean(property);
if (clusterStateSize) {
CLUSTER_STATE_SIZE = true;
} else {
throw new IllegalArgumentException("es.cluster_state.size can only be unset or [true] but was [" + property + "]");
}
}
}

if (CLUSTER_STATE_SIZE) {
deprecationLogger.deprecated("es.cluster_state.size is deprecated and will be removed in 7.0.0");

I'm going to check this with the team to be certain that there are no objections.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm going to check this with the team to be certain that there are no objections.

We discussed this today and agreed to make this the only behaviour in future: this should be the only option in 8.0 and should be the usual behaviour in 7.x, although we would support disabling it with a system property, es.auto_release_flood_stage_block in 7.x.

RoutingNode routingNode = state.getRoutingNodes().node(node);

// Only unblock index if all nodes that contain shards of it are above the node auto release threshold
if (nodeIndicesAvailableForAutoRelease(usage)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I'd like this nodeIndicesAvailableForAutoRelease to be inlined to keep it in harmony with the rest of this method.

Set<String> indicesToDisableReadOnly = autoReleaseEligibility.entrySet().stream()
.filter(Map.Entry::getValue)
.map(Map.Entry::getKey)
.filter(index -> state.getBlocks().indexBlocked(ClusterBlockLevel.WRITE, index))
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should only be contemplating removing the block if the index has the specific index-level READ_ONLY_ALLOW_DELETE block that we add here.

client.admin().indices().prepareUpdateSettings(indicesToMarkReadOnly.toArray(Strings.EMPTY_ARRAY)).
setSettings(Settings.builder().put(IndexMetaData.SETTING_READ_ONLY_ALLOW_DELETE, true).build()).execute();
client.admin().indices().prepareUpdateSettings(indicesToUpdate.toArray(Strings.EMPTY_ARRAY)).
setSettings(Settings.builder().put(IndexMetaData.SETTING_READ_ONLY_ALLOW_DELETE, readOnly).build()).execute();
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should remove the setting completely from the index metadata, not just set it to false as done here.

}

private boolean canSetAutoRelease() {
return (this.freeBytesThresholdHigh != null && this.freeBytesThresholdFloodStage != null);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this needed? I can't see that this.freeBytesThresholdHigh is ever null, and this.freeBytesThresholdFloodStage should only be null during initialisation, which I think I'd prefer to fix by setting it to new ByteSizeValue(0, ByteSizeUnit.BYTES) first.

@DaveCTurner
Copy link
Contributor

Also please don't force-push to PRs, it makes it much harder to keep track things.

@DaveCTurner
Copy link
Contributor

Superseded by #42559.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Distributed Coordination/Allocation All issues relating to the decision making around placing a shard (both master logic & on the nodes) >enhancement v7.2.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for automatic release of index block once disk frees up
4 participants