Skip to content

Fix FollowingEngineTests#testProcessOnceOnPrimary for synthetic ids#143577

Merged
fcofdez merged 6 commits intoelastic:mainfrom
fcofdez:follower-test
Mar 5, 2026
Merged

Fix FollowingEngineTests#testProcessOnceOnPrimary for synthetic ids#143577
fcofdez merged 6 commits intoelastic:mainfrom
fcofdez:follower-test

Conversation

@fcofdez
Copy link
Copy Markdown
Contributor

@fcofdez fcofdez commented Mar 4, 2026

This commit ensures that when synthetic id is enabled;
documents have the right fields needed for them to
work properly.

This commit ensures that when synthetic id is enabled the documents
have the right fields needed for them to work properly.
@fcofdez fcofdez requested review from burqen and tlrx March 4, 2026 13:45
@fcofdez fcofdez added >test Issues or PRs that are addressing/adding tests :Distributed/CCR Issues around the Cross Cluster State Replication features Team:Distributed Meta label for distributed team. labels Mar 4, 2026
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

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

String docId = Integer.toString(between(1, 100));
ParsedDocument doc = randomBoolean() ? EngineTestCase.createParsedDoc(docId, null) : nestedDocFunc.apply(docId, randomInt(3));
String docId = useSyntheticId
? TsidExtractingIdFieldMapper.createSyntheticId(new BytesRef(Integer.toString(i)), i + 10, randomIntBetween(1, 100))
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 wonder if we need that synthetic id to be a valid one? Ie making sure that the generated timestamp/routing hash are correct?

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.

This test goes really low level and most of the validations are not in place. I think that this would suffice, but happy to harden this if you think is worth it.

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'm mostly worried that the custom postings format could not work correctly if synthetic ids are invalid (since I saw deletes in this class).

But maybe it also doesn't use the custom codec at all?

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.

It uses the codec to load the synthetic id stored fields, and that seems to work. In any case, I've pushed 1affcee using a real timestamp and a non negative routing hash just in case.

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, thanks for the extra iteration.

Copy link
Copy Markdown
Contributor

@burqen burqen 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 to me, just some questions / suggestions about feature flag


public void testProcessOnceOnPrimary() throws Exception {
final Settings.Builder settingsBuilder = indexSettings(IndexVersion.current(), 1, 0).put("index.xpack.ccr.following_index", true);
boolean useSyntheticId = indexMode == IndexMode.TIME_SERIES && randomBoolean();
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.

Do we need to guard for feature flag here?

Suggested change
boolean useSyntheticId = indexMode == IndexMode.TIME_SERIES && randomBoolean();
boolean useSyntheticId = IndexSettings.TSDB_SYNTHETIC_ID_FEATURE_FLAG && indexMode == IndexMode.TIME_SERIES && randomBoolean();

case TIME_SERIES:
settingsBuilder.put("index.mode", "time_series").put("index.routing_path", "foo");
settingsBuilder.put("index.seq_no.index_options", "points_and_doc_values");
settingsBuilder.put(IndexSettings.SYNTHETIC_ID.getKey(), useSyntheticId);
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.

Only set setting explicitly if feature flag is true (if we need to guard for that)

Suggested change
settingsBuilder.put(IndexSettings.SYNTHETIC_ID.getKey(), useSyntheticId);
if (IndexSettings.TSDB_SYNTHETIC_ID_FEATURE_FLAG) {
settingsBuilder.put(IndexSettings.SYNTHETIC_ID.getKey(), useSyntheticId);
}

@fcofdez
Copy link
Copy Markdown
Contributor Author

fcofdez commented Mar 5, 2026

@elasticmachine update branch

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

This commit ensures that when synthetic id is enabled;
documents have the right fields needed for them to
work properly.
spinscale pushed a commit to spinscale/elasticsearch that referenced this pull request Mar 6, 2026
…lastic#143577)

This commit ensures that when synthetic id is enabled;
documents have the right fields needed for them to
work properly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Distributed/CCR Issues around the Cross Cluster State Replication features Team:Distributed Meta label for distributed team. >test Issues or PRs that are addressing/adding tests v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants