Skip to content

Commit d07c763

Browse files
committed
make the defaults smarter
1 parent baee3fe commit d07c763

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

server/src/main/java/org/elasticsearch/cluster/metadata/DataStream.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public DataStream(
214214
lifecycle,
215215
dataStreamOptions,
216216
new DataStreamIndices(BACKING_INDEX_PREFIX, List.copyOf(indices), rolloverOnWrite, autoShardingEvent),
217-
new DataStreamIndices(FAILURE_STORE_PREFIX, List.copyOf(failureIndices), false, null)
217+
new DataStreamIndices(FAILURE_STORE_PREFIX, List.copyOf(failureIndices), failureIndices.isEmpty(), null)
218218
);
219219
}
220220

@@ -283,7 +283,10 @@ public static DataStream read(StreamInput in) throws IOException {
283283
backingIndicesBuilder.setAutoShardingEvent(in.readOptionalWriteable(DataStreamAutoShardingEvent::new));
284284
}
285285
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_15_0)) {
286-
failureIndicesBuilder.setRolloverOnWrite(in.readBoolean())
286+
// Read the rollover on write flag from the stream, but force it on if the failure indices are empty
287+
boolean failureStoreRolloverOnWrite = in.readBoolean();
288+
failureStoreRolloverOnWrite |= failureIndices.isEmpty();
289+
failureIndicesBuilder.setRolloverOnWrite(failureStoreRolloverOnWrite)
287290
.setAutoShardingEvent(in.readOptionalWriteable(DataStreamAutoShardingEvent::new));
288291
}
289292
DataStreamOptions dataStreamOptions;
@@ -1490,7 +1493,9 @@ public void writeTo(StreamOutput out) throws IOException {
14901493
new DataStreamIndices(
14911494
FAILURE_STORE_PREFIX,
14921495
args[13] != null ? (List<Index>) args[13] : List.of(),
1493-
args[14] != null && (boolean) args[14],
1496+
// We check if the list of failure indices are empty first, forcing rollover on write to true, and if they have entries,
1497+
// then we use whatever value was previously present.
1498+
(args[13] != null && ((List<Index>) args[13]).isEmpty()) || (args[14] != null && (boolean) args[14]),
14941499
(DataStreamAutoShardingEvent) args[15]
14951500
)
14961501
)
@@ -1859,8 +1864,7 @@ protected DataStreamIndices(
18591864
// The list of indices is expected to be an immutable list. We don't create an immutable copy here, as it might have
18601865
// impact on the performance on some usages.
18611866
this.indices = indices;
1862-
// There should never be a point where rollover on write is false if there are no indices present for this set
1863-
this.rolloverOnWrite = indices.isEmpty() || rolloverOnWrite;
1867+
this.rolloverOnWrite = rolloverOnWrite;
18641868
this.autoShardingEvent = autoShardingEvent;
18651869

18661870
assert getLookup().size() == indices.size() : "found duplicate index entries in " + indices;

0 commit comments

Comments
 (0)