Skip to content

Disable OCC in update/delete-by-query for seq_no-less indices#143465

Merged
fcofdez merged 10 commits intoelastic:mainfrom
fcofdez:disable-occ-update-delete-by-query
Mar 5, 2026
Merged

Disable OCC in update/delete-by-query for seq_no-less indices#143465
fcofdez merged 10 commits intoelastic:mainfrom
fcofdez:disable-occ-update-delete-by-query

Conversation

@fcofdez
Copy link
Copy Markdown
Contributor

@fcofdez fcofdez commented Mar 3, 2026

When an index has index.disable_sequence_numbers enabled,
the update-by-query and delete-by-query actions now skip setting
ifSeqNo/ifPrimaryTerm on bulk write requests and stop requesting seq_no
in the search source. A new resolver validates that all target indices
(or their parent data streams) agree on the setting, rejecting mixed configurations.
Within a single data stream, if any backing index disables seq_no
the entire stream is treated as seq_no-disabled.

Related to #136305

When an index has `index.disable_sequence_numbers` enabled, the
update-by-query and delete-by-query actions now skip setting
ifSeqNo/ifPrimaryTerm on bulk write requests and stop requesting
seq_no in the search source. A new resolver validates that all
target indices (or their parent data streams) agree on the setting,
rejecting mixed configurations. Within a single data stream, if any
backing index disables seq_no the entire stream is treated as
seq_no-disabled.
@fcofdez fcofdez added >enhancement :Distributed/Reindex Issues relating to reindex that are not caused by issues further down Team:Distributed Meta label for distributed team. v9.4.0 labels Mar 3, 2026
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-distributed (Team:Distributed)

@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

Hi @fcofdez, I've created a changelog YAML for you.

@fcofdez fcofdez requested review from burqen and tlrx March 3, 2026 14:50
Map<String, Boolean> seqNoDisabledPerSource = new HashMap<>();
for (Index concreteIndex : concreteIndices) {
IndexMetadata indexMetadata = projectMetadata.index(concreteIndex);
boolean seqNoDisabled = hasSequenceNumbersDisabled(indexMetadata);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have the impression that we could early exit in this for loop (maybe with 2 booleans: "anySeqNoDisabled" and "anySeqNoEnabled" or something along those lines and check if they are both true).

I'm mentioning this because it's not unusual to resolve hundreds of concrete indices in requests...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue is that if the index expression is targeting multiple data streams, you kind of need to evaluate all the indices before doing the validation, otherwise you risk throwing an exception too early, i.e. if DS-2 latest index is the only one with seq_no disabled. I took this route because it's likely that a data stream would have a mix of seq_no enabled and disabled and we want to accept that scenario.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But happy to change this if we think that there are other ways to optimize this.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, let's keep it as it is.

Copy link
Copy Markdown
Member

@tlrx tlrx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I left some nits

Map<String, Boolean> seqNoDisabledPerSource = new HashMap<>();
for (Index concreteIndex : concreteIndices) {
IndexMetadata indexMetadata = projectMetadata.index(concreteIndex);
boolean seqNoDisabled = hasSequenceNumbersDisabled(indexMetadata);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, let's keep it as it is.

@fcofdez
Copy link
Copy Markdown
Contributor Author

fcofdez commented Mar 5, 2026

@elasticmachine update branch

@fcofdez fcofdez merged commit 4b54529 into elastic:main Mar 5, 2026
35 checks passed
jfreden pushed a commit to jfreden/elasticsearch that referenced this pull request Mar 5, 2026
…c#143465)

When an index has `index.disable_sequence_numbers` enabled, the
update-by-query and delete-by-query actions now skip setting
ifSeqNo/ifPrimaryTerm on bulk write requests and stop requesting
seq_no in the search source. A new resolver validates that all
target indices (or their parent data streams) agree on the setting,
rejecting mixed configurations. Within a single data stream, if any
backing index disables seq_no the entire stream is treated as
seq_no-disabled.

Related to elastic#136305
spinscale pushed a commit to spinscale/elasticsearch that referenced this pull request Mar 6, 2026
…c#143465)

When an index has `index.disable_sequence_numbers` enabled, the
update-by-query and delete-by-query actions now skip setting
ifSeqNo/ifPrimaryTerm on bulk write requests and stop requesting
seq_no in the search source. A new resolver validates that all
target indices (or their parent data streams) agree on the setting,
rejecting mixed configurations. Within a single data stream, if any
backing index disables seq_no the entire stream is treated as
seq_no-disabled.

Related to elastic#136305
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Distributed/Reindex Issues relating to reindex that are not caused by issues further down >enhancement Team:Distributed Meta label for distributed team. v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants