From fb324cf6861826f3758437ddfeb274c3ac2abb9a Mon Sep 17 00:00:00 2001 From: Poojita Raj Date: Wed, 31 Jan 2024 15:32:59 -0800 Subject: [PATCH] Modify shrink exception to be more informative Signed-off-by: Poojita Raj --- .../replication/SegmentReplicationResizeRequestIT.java | 3 ++- .../action/admin/indices/shrink/TransportResizeAction.java | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/replication/SegmentReplicationResizeRequestIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/replication/SegmentReplicationResizeRequestIT.java index fb06a97bd51c2..75f6afdd9f75a 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/replication/SegmentReplicationResizeRequestIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/replication/SegmentReplicationResizeRequestIT.java @@ -87,7 +87,8 @@ public void testCreateShrinkIndexThrowsExceptionWhenReplicasBehind() throws Exce .get() ); assertEquals( - " For index [test] replica shards haven't caught up with primary, please retry after sometime.", + "For index [test] replica shards haven't caught up with primary, please retry after sometime. " + + "Use the _cat/segment_replication/test api to check if the index is up to date (bytes_behind == 0).", exception.getMessage() ); diff --git a/server/src/main/java/org/opensearch/action/admin/indices/shrink/TransportResizeAction.java b/server/src/main/java/org/opensearch/action/admin/indices/shrink/TransportResizeAction.java index 23cd8efdcaf59..2eb01e9b44a8f 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/shrink/TransportResizeAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/shrink/TransportResizeAction.java @@ -168,9 +168,11 @@ protected void clusterManagerOperation( .getSegments() .getReplicationStats().maxBytesBehind != 0) { throw new IllegalStateException( - " For index [" + "For index [" + sourceIndex - + "] replica shards haven't caught up with primary, please retry after sometime." + + "] replica shards haven't caught up with primary, please retry after sometime. Use the _cat/segment_replication/" + + sourceIndex + + " api to check if the index is up to date (bytes_behind == 0)." ); }