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

Implement schema migration and validate storage version during boostrap #13200

Merged
merged 5 commits into from
Sep 10, 2021

Conversation

serathius
Copy link
Member

@serathius serathius commented Jul 8, 2021

Part of milestone 1 of #13168
cc @ptabor

@serathius serathius changed the title Downgrade storage Implement schema migration and panic when trying to downgrade storage Jul 9, 2021
@serathius serathius mentioned this pull request Jul 9, 2021
13 tasks
@serathius serathius force-pushed the downgrade-storage branch 4 times, most recently from 163b47a to 77ac6e9 Compare July 9, 2021 13:08
@serathius serathius requested a review from ptabor July 12, 2021 08:51
Copy link
Contributor

@lilic lilic left a comment

Choose a reason for hiding this comment

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

Couple of comments and suggestions 🎉

I would find it useful to maybe add a bit more context to the description of the PRs in the future, as its harder to follow if I miss one or two. I read the design doc and the issue but still might be useful IMHO, thank you!

server/storage/schema/schema.go Outdated Show resolved Hide resolved
server/storage/schema/schema.go Outdated Show resolved Hide resolved
server/storage/schema/schema.go Outdated Show resolved Hide resolved
server/storage/schema/schema.go Outdated Show resolved Hide resolved
server/storage/schema/schema.go Outdated Show resolved Hide resolved
server/storage/schema/schema_test.go Outdated Show resolved Hide resolved
server/storage/schema/confstate_test.go Outdated Show resolved Hide resolved
@serathius serathius force-pushed the downgrade-storage branch 2 times, most recently from 631ad45 to 284b99e Compare July 14, 2021 13:24
@serathius
Copy link
Member Author

PTAL @lilic

Copy link
Contributor

@lilic lilic left a comment

Choose a reason for hiding this comment

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

Couple more comments. I do believe we need more consensus on the breaking change here.

cc @hexfusion

server/etcdserver/server.go Outdated Show resolved Hide resolved
server/etcdserver/version/version.go Outdated Show resolved Hide resolved
server/etcdserver/version/version.go Outdated Show resolved Hide resolved
server/etcdserver/version/version.go Outdated Show resolved Hide resolved
server/etcdserver/version/version.go Outdated Show resolved Hide resolved
server/etcdserver/version/version.go Outdated Show resolved Hide resolved
server/etcdserver/version/version_test.go Outdated Show resolved Hide resolved
@serathius serathius force-pushed the downgrade-storage branch 6 times, most recently from e44ec67 to 16e916d Compare July 16, 2021 09:30
@serathius
Copy link
Member Author

Addressed all issues, PTAL

@serathius serathius force-pushed the downgrade-storage branch 2 times, most recently from 6e02060 to af58a2d Compare July 26, 2021 16:47
@serathius
Copy link
Member Author

Send an announcement about the breaking change to make sure community is aware of it. https://groups.google.com/g/etcd-dev/c/-u_vl_G-nRg

server/etcdserver/server.go Outdated Show resolved Hide resolved
server/storage/schema/schema.go Show resolved Hide resolved
server/storage/schema/schema.go Outdated Show resolved Hide resolved
server/storage/schema/schema.go Outdated Show resolved Hide resolved
server/storage/schema/schema.go Outdated Show resolved Hide resolved
server/storage/schema/schema.go Outdated Show resolved Hide resolved
@serathius serathius force-pushed the downgrade-storage branch 4 times, most recently from 898223e to 3ad6f79 Compare August 4, 2021 09:54
return revert, nil
}

func currentStateFieldAction(tx backend.BatchTx, bucket backend.Bucket, fieldName []byte) action {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add comment

Copy link
Contributor

Choose a reason for hiding this comment

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

(make it clear that it produces a rollback action)

Copy link
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 encapsulate this function? Maybe for better readable just writing the logic in unsafeDo functions?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it's clearer to have in separate function, just the original name was bad. I changed the name to restoreFieldValueAction, please let me know what you think.

Copy link
Contributor

@jingyih jingyih left a comment

Choose a reason for hiding this comment

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

Thanks for the great work! I added few comments. Overall looks good.

return revert, nil
}

func currentStateFieldAction(tx backend.BatchTx, bucket backend.Bucket, fieldName []byte) action {
Copy link
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 encapsulate this function? Maybe for better readable just writing the logic in unsafeDo functions?

server/storage/schema/actions_test.go Show resolved Hide resolved
server/etcdserver/server.go Show resolved Hide resolved
@serathius serathius force-pushed the downgrade-storage branch 2 times, most recently from e455d25 to bc6a0ac Compare September 7, 2021 09:07
return nil
}

// unsafeExecuteInReverseOrder executes actions in revered order. Will panic on
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: s/revered/reversed

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

server/storage/schema/actions_test.go Show resolved Hide resolved
Copy link
Contributor

@jingyih jingyih 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 again!

server/storage/schema/migration.go Outdated Show resolved Hide resolved
server/storage/schema/migration.go Outdated Show resolved Hide resolved
@serathius serathius force-pushed the downgrade-storage branch 6 times, most recently from dd72e7f to bc6a0ac Compare September 8, 2021 12:15
@serathius
Copy link
Member Author

serathius commented Sep 8, 2021

Latest changes have broken integrations tests in a way that I don't understand nor can reproduce locally. Reverting to state from yesterday. Will try to reapply latest changes but it will take multiple iterations.

@serathius serathius force-pushed the downgrade-storage branch 4 times, most recently from 40a6323 to aed03ad Compare September 9, 2021 10:11
serathius and others added 5 commits September 10, 2021 10:16
…change and panic if unknown storage version is found

Storage version should follow cluster version. During upgrades this
should be immidiate as storage version can be always upgraded as storage
is backward compatible. During downgrades it will be delayed and will
require time for incompatible changes to be snapshotted.

As storage version change can happen long after cluster is running, we
need to add a step during bootstrap to validate if loaded data can be
understood by migrator.
Co-authored-by: Lili Cosic <cosiclili@gmail.com>
@ptabor ptabor merged commit c2937d7 into etcd-io:main Sep 10, 2021
@serathius serathius changed the title Implement schema migration and panic when trying to downgrade storage Implement schema migration and validate storage version during boostrap Oct 11, 2021
@serathius serathius deleted the downgrade-storage branch June 15, 2023 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants