From 1987bb2205102e91d4d43fa72e58e350713ae002 Mon Sep 17 00:00:00 2001 From: Niels Bauman Date: Tue, 9 Apr 2024 09:24:37 +0200 Subject: [PATCH 1/3] Don't overwrite DataStream.rolloverOnWrite flag on failure store rollover --- .../java/org/elasticsearch/cluster/metadata/DataStream.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/DataStream.java b/server/src/main/java/org/elasticsearch/cluster/metadata/DataStream.java index 364a1b31ceeba..d4fd57427793b 100644 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/DataStream.java +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/DataStream.java @@ -527,7 +527,7 @@ public DataStream unsafeRolloverFailureStore(Index writeIndex, long generation) lifecycle, failureStore, failureIndices, - false, + rolloverOnWrite, autoShardingEvent ); } From ace0256b96fa216b8373bc3c2a55c79b2d1de4b5 Mon Sep 17 00:00:00 2001 From: Niels Bauman Date: Tue, 9 Apr 2024 10:45:10 +0200 Subject: [PATCH 2/3] Add test --- .../org/elasticsearch/cluster/metadata/DataStreamTests.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/server/src/test/java/org/elasticsearch/cluster/metadata/DataStreamTests.java b/server/src/test/java/org/elasticsearch/cluster/metadata/DataStreamTests.java index f086b52c1b491..a600d3f31e559 100644 --- a/server/src/test/java/org/elasticsearch/cluster/metadata/DataStreamTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/metadata/DataStreamTests.java @@ -177,6 +177,8 @@ public void testRollover() { assertThat(rolledDs.getIndices().size(), equalTo(ds.getIndices().size() + 1)); assertTrue(rolledDs.getIndices().containsAll(ds.getIndices())); assertTrue(rolledDs.getIndices().contains(rolledDs.getWriteIndex())); + // Irrespective of whether the rollover was performed lazily, rolloverOnWrite should always be set to false after rollover. + assertFalse(rolledDs.rolloverOnWrite()); } public void testRolloverWithConflictingBackingIndexName() { @@ -272,6 +274,8 @@ public void testRolloverFailureStore() { assertThat(rolledDs.getName(), equalTo(ds.getName())); assertThat(rolledDs.getGeneration(), equalTo(ds.getGeneration() + 1)); assertThat(rolledDs.getIndices().size(), equalTo(ds.getIndices().size())); + // Ensure rolloverOnWrite flag hasn't changed when rolling over a failure store. + assertThat(rolledDs.rolloverOnWrite(), equalTo(ds.rolloverOnWrite())); assertThat(rolledDs.getFailureIndices().size(), equalTo(ds.getFailureIndices().size() + 1)); assertTrue(rolledDs.getIndices().containsAll(ds.getIndices())); assertTrue(rolledDs.getIndices().contains(rolledDs.getWriteIndex())); From d48f975acf4f58ad84367a5d30c036b15004b81c Mon Sep 17 00:00:00 2001 From: Niels Bauman Date: Tue, 9 Apr 2024 19:49:04 +0200 Subject: [PATCH 3/3] Update comment wording --- .../org/elasticsearch/cluster/metadata/DataStreamTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/test/java/org/elasticsearch/cluster/metadata/DataStreamTests.java b/server/src/test/java/org/elasticsearch/cluster/metadata/DataStreamTests.java index a600d3f31e559..d54fcbd8a9e41 100644 --- a/server/src/test/java/org/elasticsearch/cluster/metadata/DataStreamTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/metadata/DataStreamTests.java @@ -274,7 +274,7 @@ public void testRolloverFailureStore() { assertThat(rolledDs.getName(), equalTo(ds.getName())); assertThat(rolledDs.getGeneration(), equalTo(ds.getGeneration() + 1)); assertThat(rolledDs.getIndices().size(), equalTo(ds.getIndices().size())); - // Ensure rolloverOnWrite flag hasn't changed when rolling over a failure store. + // Ensure that the rolloverOnWrite flag hasn't changed when rolling over a failure store. assertThat(rolledDs.rolloverOnWrite(), equalTo(ds.rolloverOnWrite())); assertThat(rolledDs.getFailureIndices().size(), equalTo(ds.getFailureIndices().size() + 1)); assertTrue(rolledDs.getIndices().containsAll(ds.getIndices()));