Skip to content

Return sentinel values from GET calls when sequence numbers are disabled#143575

Merged
elasticsearchmachine merged 4 commits intoelastic:mainfrom
romseygeek:seqno/sentinels-in-get-requests
Mar 5, 2026
Merged

Return sentinel values from GET calls when sequence numbers are disabled#143575
elasticsearchmachine merged 4 commits intoelastic:mainfrom
romseygeek:seqno/sentinels-in-get-requests

Conversation

@romseygeek
Copy link
Copy Markdown
Contributor

@romseygeek romseygeek commented Mar 4, 2026

The _seq_no and _primary_term fields will return -2 for all GET and MGET
calls, making it clearer that these fields are not available for searching or
versioning when sequence numbers have been disabled at the index level.

Related to #136305

The _seq_no and _primary_term fields will return -1 for all GET and MGET
calls, making it clearer that these fields are not available for searching
or versioning when sequence numbers have been disabled at the index level.
@romseygeek romseygeek requested review from fcofdez and tlrx March 4, 2026 12:35
@romseygeek romseygeek self-assigned this Mar 4, 2026
@romseygeek romseygeek added >non-issue :Distributed/Engine Anything around managing Lucene and the Translog in an open shard. v9.4.0 labels Mar 4, 2026
@elasticsearchmachine elasticsearchmachine added the Team:Distributed Meta label for distributed team. label Mar 4, 2026
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

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

Copy link
Copy Markdown
Contributor

@fcofdez fcofdez left a comment

Choose a reason for hiding this comment

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

Looks good! I left a couple of suggestions around testing

.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
)
);
client().prepareIndex(index).setId("1").setSource("field", "value").get();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can we randomly refresh/flush so we exercise all the get paths?

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.

Yes, ideally we test after refresh, after flush, after nothing (still in translog) etc

);
client().prepareIndex(index).setId("1").setSource("field", "value").get();

GetResponse getResponse = client().prepareGet(index, "1").get();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

maybe we can randomly set realtime too?


GetResponse getResponse = client().prepareGet(index, "1").get();
assertTrue(getResponse.isExists());
assertThat(getResponse.getSeqNo(), equalTo(SequenceNumbers.UNASSIGNED_SEQ_NO));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think that we discussed returning a different sentinel value for this case, but I see that it can add some complexity, so I'm ok with this.

.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
)
);
client().prepareIndex(index).setId("1").setSource("field", "value").get();
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.

Yes, ideally we test after refresh, after flush, after nothing (still in translog) etc

assertThat(getResponse.getPrimaryTerm(), equalTo(SequenceNumbers.UNASSIGNED_PRIMARY_TERM));

MultiGetResponse multiGetResponse = client().prepareMultiGet().add(index, "1").get();
assertThat(multiGetResponse.getResponses().length, equalTo(1));
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.

nit: maybe worth testing on more than1 document

Copy link
Copy Markdown
Contributor

@fcofdez fcofdez left a comment

Choose a reason for hiding this comment

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

LGTM

@romseygeek romseygeek added the auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) label Mar 5, 2026
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

Settings settings = Settings.builder()
.put(defaultSettings.getSettings())
.put(IndexSettings.DISABLE_SEQUENCE_NUMBERS.getKey(), true)
.put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())
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.

If you can you add SEQ_NO_INDEX_OPTIONS_SETTING to docs values only already that's great.

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'll add it to #143583.

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.

Sorry, the bot got there first!

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.

No pb :)

@elasticsearchmachine elasticsearchmachine merged commit 7b7ca5f into elastic:main Mar 5, 2026
35 checks passed
@romseygeek romseygeek deleted the seqno/sentinels-in-get-requests branch March 5, 2026 12:59
jfreden pushed a commit to jfreden/elasticsearch that referenced this pull request Mar 5, 2026
…led (elastic#143575)

The _seq_no and _primary_term fields will return -2 for all GET and MGET
calls, making it clearer that these fields are not available for
searching or  versioning when sequence numbers have been disabled at the
index level.

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

The _seq_no and _primary_term fields will return -2 for all GET and MGET
calls, making it clearer that these fields are not available for
searching or  versioning when sequence numbers have been disabled at the
index level.

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

Labels

auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) :Distributed/Engine Anything around managing Lucene and the Translog in an open shard. >non-issue 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