Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reinstate RepositoryData BwC #100405

Conversation

DaveCTurner
Copy link
Contributor

This commit moves back to using a "major.minor.patch" string for the
version field in snapshots stored in RepositoryData, using the marker
string "8.11.0" to allow older versions to filter out newer snapshots
and adding a new index_version field alongside.

This format is fully backwardly-compatible, except that it trips an
assertion in the versions of 8.10.x released today. When running without
assertions enabled, things work correctly in all versions.

Relates #98454

This commit moves back to using a `"major.minor.patch"` string for the
version field in snapshots stored in `RepositoryData`, using the marker
string `"8.11.0"` to allow older versions to filter out newer snapshots
and adding a new `index_version` field alongside.

This format is fully backwardly-compatible, except that it trips an
assertion in the versions of 8.10.x released today. When running without
assertions enabled, things work correctly in all versions.

Relates elastic#98454
@DaveCTurner DaveCTurner added >bug :Distributed Coordination/Snapshot/Restore Anything directly related to the `_snapshot/*` APIs v8.11.1 v8.12.0 labels Oct 6, 2023
@elasticsearchmachine elasticsearchmachine added the Team:Distributed (Obsolete) Meta label for distributed team (obsolete). Replaced by Distributed Indexing/Coordination. label Oct 6, 2023
@elasticsearchmachine
Copy link
Collaborator

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

@elasticsearchmachine
Copy link
Collaborator

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

@DaveCTurner DaveCTurner added the test-full-bwc Trigger full BWC version matrix tests label Oct 6, 2023
@DaveCTurner
Copy link
Contributor Author

This is the substantial part of the fix for #98454. It is independent of #100401 as written, but once #100401 is merged and backported to 8.10 we will be able to re-enable assertions in the bwc tests against newer 8.10.x versions.

I've opened it here against 8.11 because that means the bwc test suite will work here. Once approved I will make this change in main except leaving the test suite muted, then backport it to 8.11, and then go back and unmute the tests.

Copy link
Contributor

@henningandersen henningandersen left a comment

Choose a reason for hiding this comment

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

This looks good. I have one question only.

if (version != null) {
if (version.before(IndexVersion.V_8_9_0)) {
builder.field(VERSION, Version.fromId(version.id()).toString());
if (version != null && version.id() != NUMERIC_INDEX_VERSION_MARKER.id()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would we not want to retain the version field if it is 8.11.0? I think this nulls it out, which would trigger an old version to read the details out I think.

Definitely a minor point (would require 8.11+ writing data, then 8.9 roundtrip, then 8.11+ roundtrip and finally 8.9 read to be a problem), but seems slightly better anyway. On the other hand, I am sure there is a good reason for this that I have not realized?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes in fact this does not especially matter since we will re-read the SnapshotInfo either way. I added this to help with forensics a little: if we encounter a RepositoryData in the wild with "version":"8.11.0" and no "index_version" field alongside it then we know that it must have been written by a version before 8.11.0.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok. So IIUC, 8.9 will parse the snapshot info's version as something like 8.50.00 and be happy about it.

Would it then be simpler to always null out the version field always (in 8.11+) and only write the index_version field? Any prior version would then read the details from snapshot info.

Copy link
Contributor

Choose a reason for hiding this comment

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

I was wondering the exact same thing (why we need version.id() != NUMERIC_INDEX_VERSION_MARKER.id()).
So 8.9 should keep "8.11" as a string version, but will clear out the numeric id out in the roundtrip; then 8.11 will read this (OK). When it's time for 8.11 to write, this if should not be passing, so no version or index_version will be written out.
But I assume you are saying this does not matter, because version will have be updated before writing (will not be 8.11 anymore, but something like 8_500_003)?

Copy link
Contributor

Choose a reason for hiding this comment

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

If the version is null when reading, we read it from the snapshot info, also in prior versions. SnapshotInfo uses (and used) and int as xcontent serialization so a new version 8_500_003 would be parsed as 8.50.03 by some old ES version and thus be parseable (but ofc not restorable).

Copy link
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

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

One question

if (version.before(IndexVersion.V_8_9_0)) {
builder.field(VERSION, Version.fromId(version.id()).toString());
if (version != null && version.id() != NUMERIC_INDEX_VERSION_MARKER.id()) {
if (version.onOrAfter(IndexVersion.V_8_500_000)) {
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps I'm missing something, but I thought the consensus reached was that this comparison should be on minVersion since that is effectively the format version of the entire repository data?

Copy link
Contributor

Choose a reason for hiding this comment

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

That is not a problem with this approach, since the NUMERIC_INDEX_VERSION_MARKER_STRING is compatible with older releases.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, technically we're not changing the format version of the entire repository data here, we're just refining the format of the snapshot version slightly. The format of older version numbers remains unchanged, newer version numbers are formatted such that older versions will see them as 8.11.0, but newer versions will interpret them correctly.

In fact the round-tripping problem doesn't matter here, because the authoritative source of a snapshot version is the SnapshotInfo file, and we already have a mechanism to re-read these files if we find we do not have everything we expect.

Copy link
Contributor

@henningandersen henningandersen left a comment

Choose a reason for hiding this comment

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

LGTM.

@DaveCTurner
Copy link
Contributor Author

#100447 is effectively the same change, but against main, and I expect it not to need any backport shenanigans now so I'm closing this.

@DaveCTurner DaveCTurner closed this Oct 6, 2023
@DaveCTurner DaveCTurner deleted the 2023/10/06/RepositoryData-bwc-fix-2-8.11 branch October 6, 2023 18:01
@DaveCTurner DaveCTurner restored the 2023/10/06/RepositoryData-bwc-fix-2-8.11 branch June 17, 2024 06:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Distributed Coordination/Snapshot/Restore Anything directly related to the `_snapshot/*` APIs Team:Distributed (Obsolete) Meta label for distributed team (obsolete). Replaced by Distributed Indexing/Coordination. test-full-bwc Trigger full BWC version matrix tests v8.11.1 v8.12.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants