From ec561afdd1d9c1daff344d197538a82fba627e2f Mon Sep 17 00:00:00 2001 From: Valeriy Khakhutskyy <1292899+valeriy42@users.noreply.github.com> Date: Thu, 11 Sep 2025 14:14:21 +0200 Subject: [PATCH 1/4] extend log message --- .../autodetect/JobModelSnapshotUpgrader.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/JobModelSnapshotUpgrader.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/JobModelSnapshotUpgrader.java index d42eb8f748b51..4c667bc0c09d8 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/JobModelSnapshotUpgrader.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/JobModelSnapshotUpgrader.java @@ -196,13 +196,19 @@ private void deleteOlderSnapshotDoc(SearchResponse searchResponse, Consumer { - logger.warn( - () -> format( - "[%s] [%s] failed to delete old snapshot [%s] result document", - jobId, - snapshotId, - ModelSizeStats.RESULT_TYPE_FIELD.getPreferredName() - ), + logger.warn( + () -> { + String baseMessage = format( + "[%s] [%s] failed to delete old snapshot [%s] result document", + jobId, + snapshotId, + ModelSizeStats.RESULT_TYPE_FIELD.getPreferredName() + ); + if (e instanceof org.elasticsearch.cluster.block.ClusterBlockException) { + return baseMessage + ", the results index should be writable to detele the model snapshot"; + } + return baseMessage; + }, e ); }), () -> runAfter.accept(null))); From 1f65c46e88e4ca297b401c8a48503820c7003dbd Mon Sep 17 00:00:00 2001 From: elasticsearchmachine Date: Thu, 11 Sep 2025 12:42:57 +0000 Subject: [PATCH 2/4] [CI] Auto commit changes from spotless --- .../autodetect/JobModelSnapshotUpgrader.java | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/JobModelSnapshotUpgrader.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/JobModelSnapshotUpgrader.java index 4c667bc0c09d8..65eb83582417f 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/JobModelSnapshotUpgrader.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/JobModelSnapshotUpgrader.java @@ -196,21 +196,18 @@ private void deleteOlderSnapshotDoc(SearchResponse searchResponse, Consumer { - logger.warn( - () -> { - String baseMessage = format( - "[%s] [%s] failed to delete old snapshot [%s] result document", - jobId, - snapshotId, - ModelSizeStats.RESULT_TYPE_FIELD.getPreferredName() - ); - if (e instanceof org.elasticsearch.cluster.block.ClusterBlockException) { - return baseMessage + ", the results index should be writable to detele the model snapshot"; - } - return baseMessage; - }, - e - ); + logger.warn(() -> { + String baseMessage = format( + "[%s] [%s] failed to delete old snapshot [%s] result document", + jobId, + snapshotId, + ModelSizeStats.RESULT_TYPE_FIELD.getPreferredName() + ); + if (e instanceof org.elasticsearch.cluster.block.ClusterBlockException) { + return baseMessage + ", the results index should be writable to detele the model snapshot"; + } + return baseMessage; + }, e); }), () -> runAfter.accept(null))); } From 7b1e81e6937b373d27bea7bd91074928fb038935 Mon Sep 17 00:00:00 2001 From: Valeriy Khakhutskyy <1292899+valeriy42@users.noreply.github.com> Date: Thu, 11 Sep 2025 15:40:35 +0200 Subject: [PATCH 3/4] add api reference --- .../elasticsearch/common/ReferenceDocs.java | 3 +- .../common/reference-docs-links.txt | 1 + .../autodetect/JobModelSnapshotUpgrader.java | 31 ++++++++++--------- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/common/ReferenceDocs.java b/server/src/main/java/org/elasticsearch/common/ReferenceDocs.java index 41faefaafc636..b11cdb16a365d 100644 --- a/server/src/main/java/org/elasticsearch/common/ReferenceDocs.java +++ b/server/src/main/java/org/elasticsearch/common/ReferenceDocs.java @@ -25,7 +25,7 @@ /** * Encapsulates links to pages in the reference docs, so that for example we can include URLs in logs and API outputs. Each instance's * {@link #toString()} yields (a string representation of) a URL for the relevant docs. Links are defined in the resource file - * {@code reference-docs-links.txt} which must include definitions for exactly the set of values of this enum. + * {@codeorg.elasticsearch.common.ReferenceDocs} which must include definitions for exactly the set of values of this enum. */ public enum ReferenceDocs { /* @@ -85,6 +85,7 @@ public enum ReferenceDocs { SECURE_SETTINGS, CLUSTER_SHARD_LIMIT, DEPLOY_CLOUD_DIFF_FROM_STATEFUL, + DELETE_INDEX_BLOCK // this comment keeps the ';' on the next line so every entry above has a trailing ',' which makes the diff for adding new links cleaner ; diff --git a/server/src/main/resources/org/elasticsearch/common/reference-docs-links.txt b/server/src/main/resources/org/elasticsearch/common/reference-docs-links.txt index 50732d9289be5..5d8ae6c5498a5 100644 --- a/server/src/main/resources/org/elasticsearch/common/reference-docs-links.txt +++ b/server/src/main/resources/org/elasticsearch/common/reference-docs-links.txt @@ -47,3 +47,4 @@ ALLOCATION_EXPLAIN_MAX_RETRY troubleshoot/ela SECURE_SETTINGS deploy-manage/security/secure-settings CLUSTER_SHARD_LIMIT reference/elasticsearch/configuration-reference/miscellaneous-cluster-settings#cluster-shard-limit DEPLOY_CLOUD_DIFF_FROM_STATEFUL deploy-manage/deploy/elastic-cloud/differences-from-other-elasticsearch-offerings +DELETE_INDEX_BLOCK api/doc/elasticsearch/operation/operation-indices-remove-block diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/JobModelSnapshotUpgrader.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/JobModelSnapshotUpgrader.java index 4c667bc0c09d8..d270e00f78e12 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/JobModelSnapshotUpgrader.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/JobModelSnapshotUpgrader.java @@ -17,6 +17,7 @@ import org.elasticsearch.action.support.WriteRequest; import org.elasticsearch.client.internal.Client; import org.elasticsearch.common.CheckedSupplier; +import org.elasticsearch.common.ReferenceDocs; import org.elasticsearch.common.util.concurrent.AbstractRunnable; import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException; import org.elasticsearch.common.util.concurrent.ThreadContext; @@ -196,21 +197,21 @@ private void deleteOlderSnapshotDoc(SearchResponse searchResponse, Consumer { - logger.warn( - () -> { - String baseMessage = format( - "[%s] [%s] failed to delete old snapshot [%s] result document", - jobId, - snapshotId, - ModelSizeStats.RESULT_TYPE_FIELD.getPreferredName() - ); - if (e instanceof org.elasticsearch.cluster.block.ClusterBlockException) { - return baseMessage + ", the results index should be writable to detele the model snapshot"; - } - return baseMessage; - }, - e - ); + logger.warn(() -> { + String baseMessage = format( + "[%s] [%s] failed to delete old snapshot [%s] result document", + jobId, + snapshotId, + ModelSizeStats.RESULT_TYPE_FIELD.getPreferredName() + ); + if (e instanceof org.elasticsearch.cluster.block.ClusterBlockException) { + return baseMessage + + ". Remove the write block from the results index to delete the model snapshot. See " + + ReferenceDocs.DELETE_INDEX_BLOCK + + " for details."; + } + return baseMessage; + }, e); }), () -> runAfter.accept(null))); } From 6951dc00b51acbcad29a02f5085f1a9954774441 Mon Sep 17 00:00:00 2001 From: Valeriy Khakhutskyy <1292899+valeriy42@users.noreply.github.com> Date: Fri, 12 Sep 2025 12:48:02 +0200 Subject: [PATCH 4/4] fix ReferenceDocs --- .../src/main/java/org/elasticsearch/common/ReferenceDocs.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/common/ReferenceDocs.java b/server/src/main/java/org/elasticsearch/common/ReferenceDocs.java index b11cdb16a365d..2567268415051 100644 --- a/server/src/main/java/org/elasticsearch/common/ReferenceDocs.java +++ b/server/src/main/java/org/elasticsearch/common/ReferenceDocs.java @@ -25,7 +25,7 @@ /** * Encapsulates links to pages in the reference docs, so that for example we can include URLs in logs and API outputs. Each instance's * {@link #toString()} yields (a string representation of) a URL for the relevant docs. Links are defined in the resource file - * {@codeorg.elasticsearch.common.ReferenceDocs} which must include definitions for exactly the set of values of this enum. + * {@code reference-docs-links.txt} which must include definitions for exactly the set of values of this enum. */ public enum ReferenceDocs { /* @@ -85,7 +85,7 @@ public enum ReferenceDocs { SECURE_SETTINGS, CLUSTER_SHARD_LIMIT, DEPLOY_CLOUD_DIFF_FROM_STATEFUL, - DELETE_INDEX_BLOCK + DELETE_INDEX_BLOCK, // this comment keeps the ';' on the next line so every entry above has a trailing ',' which makes the diff for adding new links cleaner ;