浏览代码

Always auto-release the flood-stage block (#45274)

Removes support for using a system property to disable the automatic release of
the write block applied when a node exceeds the flood-stage watermark.

Relates #42559
David Turner 6 年之前
父节点
当前提交
bc31ea752e

+ 2 - 0
docs/reference/migration/migrate_8_0.asciidoc

@@ -12,6 +12,7 @@ See also <<release-highlights>> and <<es-release-notes>>.
 coming[8.0.0]
 
 * <<breaking_80_analysis_changes>>
+* <<breaking_80_allocation_changes>>
 * <<breaking_80_discovery_changes>>
 * <<breaking_80_mappings_changes>>
 * <<breaking_80_packaging_changes>>
@@ -51,6 +52,7 @@ Elasticsearch 7.x in order to be readable by Elasticsearch 8.x.
 // end::notable-breaking-changes[]
 
 include::migrate_8_0/analysis.asciidoc[]
+include::migrate_8_0/allocation.asciidoc[]
 include::migrate_8_0/discovery.asciidoc[]
 include::migrate_8_0/mappings.asciidoc[]
 include::migrate_8_0/packaging.asciidoc[]

+ 22 - 0
docs/reference/migration/migrate_8_0/allocation.asciidoc

@@ -0,0 +1,22 @@
+[float]
+[[breaking_80_allocation_changes]]
+=== Allocation changes
+
+//NOTE: The notable-breaking-changes tagged regions are re-used in the
+//Installation and Upgrade Guide
+
+//tag::notable-breaking-changes[]
+
+// end::notable-breaking-changes[]
+
+[float]
+[[breaking_80_allocation_change_flood_stage_block_always_removed]]
+==== Auto-release flood-stage block no longer optional
+
+If a node exceeds the flood-stage disk watermark then we add a block to all of
+its indices to prevent further writes as a last-ditch attempt to prevent the
+node completely exhausting its disk space. By default, from 7.4 onwards the
+block is automatically removed when a node drops below the high watermark
+again, but this behaviour could be disabled by setting the system property
+`es.disk.auto_release_flood_stage_block` to `false`. This behaviour is no
+longer optional, and this system property must now not be set.

+ 0 - 2
docs/reference/modules/cluster/disk_allocator.asciidoc

@@ -42,8 +42,6 @@ shards allocated on the node that has at least one disk exceeding the flood
 stage. This is a last resort to prevent nodes from running out of disk space.
 The index block is automatically released once the disk utilization falls below
 the high watermark.
-The automatic release can however be disabled in 7.x through a system property
-`es.disk.auto_release_flood_stage_block`
 
 NOTE: You can not mix the usage of percentage values and byte values within
 these settings. Either all are set to percentage values, or all are set to byte

+ 4 - 22
server/src/main/java/org/elasticsearch/cluster/routing/allocation/DiskThresholdMonitor.java

@@ -24,7 +24,6 @@ import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.message.ParameterizedMessage;
-import org.elasticsearch.Version;
 import org.elasticsearch.action.ActionListener;
 import org.elasticsearch.action.support.GroupedActionListener;
 import org.elasticsearch.client.Client;
@@ -40,7 +39,6 @@ import org.elasticsearch.cluster.routing.ShardRouting;
 import org.elasticsearch.common.Priority;
 import org.elasticsearch.common.Strings;
 import org.elasticsearch.common.collect.ImmutableOpenMap;
-import org.elasticsearch.common.logging.DeprecationLogger;
 import org.elasticsearch.common.settings.ClusterSettings;
 import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.common.util.set.Sets;
@@ -71,7 +69,6 @@ public class DiskThresholdMonitor {
     private final RerouteService rerouteService;
     private final AtomicLong lastRunTimeMillis = new AtomicLong(Long.MIN_VALUE);
     private final AtomicBoolean checkInProgress = new AtomicBoolean();
-    private final DeprecationLogger deprecationLogger = new DeprecationLogger(logger);
 
     public DiskThresholdMonitor(Settings settings, Supplier<ClusterState> clusterStateSupplier, ClusterSettings clusterSettings,
                                 Client client, LongSupplier currentTimeMillisSupplier, RerouteService rerouteService) {
@@ -80,10 +77,6 @@ public class DiskThresholdMonitor {
         this.rerouteService = rerouteService;
         this.diskThresholdSettings = new DiskThresholdSettings(settings, clusterSettings);
         this.client = client;
-        if (diskThresholdSettings.isAutoReleaseIndexEnabled() == false) {
-            deprecationLogger.deprecated("[{}] will be removed in version {}",
-                DiskThresholdSettings.AUTO_RELEASE_INDEX_ENABLED_KEY, Version.V_7_4_0.major + 1);
-        }
     }
 
     /**
@@ -228,16 +221,7 @@ public class DiskThresholdMonitor {
             .collect(Collectors.toSet());
 
         if (indicesToAutoRelease.isEmpty() == false) {
-            if (diskThresholdSettings.isAutoReleaseIndexEnabled()) {
-                logger.info("releasing read-only-allow-delete block on indices: [{}]", indicesToAutoRelease);
-                updateIndicesReadOnly(indicesToAutoRelease, listener, false);
-            } else {
-                deprecationLogger.deprecated("[{}] will be removed in version {}",
-                    DiskThresholdSettings.AUTO_RELEASE_INDEX_ENABLED_KEY, Version.V_7_4_0.major + 1);
-                logger.debug("[{}] disabled, not releasing read-only-allow-delete block on indices: [{}]",
-                    DiskThresholdSettings.AUTO_RELEASE_INDEX_ENABLED_KEY, indicesToAutoRelease);
-                listener.onResponse(null);
-            }
+            updateIndicesReadOnly(indicesToAutoRelease, listener, false);
         } else {
             listener.onResponse(null);
         }
@@ -254,11 +238,9 @@ public class DiskThresholdMonitor {
                                                            Set<String> indicesToMarkIneligibleForAutoRelease) {
         for (RoutingNode routingNode : routingNodes) {
             if (usages.containsKey(routingNode.nodeId()) == false) {
-                if (routingNode != null) {
-                    for (ShardRouting routing : routingNode) {
-                        String indexName = routing.index().getName();
-                        indicesToMarkIneligibleForAutoRelease.add(indexName);
-                    }
+                for (ShardRouting routing : routingNode) {
+                    String indexName = routing.index().getName();
+                    indicesToMarkIneligibleForAutoRelease.add(indexName);
                 }
             }
         }

+ 5 - 13
server/src/main/java/org/elasticsearch/cluster/routing/allocation/DiskThresholdSettings.java

@@ -20,6 +20,7 @@
 package org.elasticsearch.cluster.routing.allocation;
 
 import org.elasticsearch.ElasticsearchParseException;
+import org.elasticsearch.Version;
 import org.elasticsearch.common.settings.ClusterSettings;
 import org.elasticsearch.common.settings.Setting;
 import org.elasticsearch.common.settings.Settings;
@@ -72,18 +73,13 @@ public class DiskThresholdSettings {
     private volatile TimeValue rerouteInterval;
     private volatile Double freeDiskThresholdFloodStage;
     private volatile ByteSizeValue freeBytesThresholdFloodStage;
-    private static final boolean autoReleaseIndexEnabled;
-    public static final String AUTO_RELEASE_INDEX_ENABLED_KEY = "es.disk.auto_release_flood_stage_block";
 
     static {
+        assert Version.CURRENT.major == Version.V_7_0_0.major + 1; // this check is unnecessary in v9
+        final String AUTO_RELEASE_INDEX_ENABLED_KEY = "es.disk.auto_release_flood_stage_block";
         final String property = System.getProperty(AUTO_RELEASE_INDEX_ENABLED_KEY);
-        if (property == null) {
-            autoReleaseIndexEnabled = true;
-        } else if (Boolean.FALSE.toString().equals(property)){
-            autoReleaseIndexEnabled = false;
-        } else {
-            throw new IllegalArgumentException(AUTO_RELEASE_INDEX_ENABLED_KEY + " may only be unset or set to [false] but was [" +
-                property + "]");
+        if (property != null) {
+            throw new IllegalArgumentException("system property [" + AUTO_RELEASE_INDEX_ENABLED_KEY + "] may not be set");
         }
     }
 
@@ -300,10 +296,6 @@ public class DiskThresholdSettings {
         return freeBytesThresholdFloodStage;
     }
 
-    public boolean isAutoReleaseIndexEnabled() {
-        return autoReleaseIndexEnabled;
-    }
-
     public boolean includeRelocations() {
         return includeRelocations;
     }

+ 0 - 1
server/src/test/java/org/elasticsearch/cluster/routing/allocation/DiskThresholdSettingsTests.java

@@ -47,7 +47,6 @@ public class DiskThresholdSettingsTests extends ESTestCase {
         assertTrue(diskThresholdSettings.includeRelocations());
         assertEquals(zeroBytes, diskThresholdSettings.getFreeBytesThresholdFloodStage());
         assertEquals(5.0D, diskThresholdSettings.getFreeDiskThresholdFloodStage(), 0.0D);
-        assertTrue(diskThresholdSettings.isAutoReleaseIndexEnabled());
     }
 
     public void testUpdate() {