-
Notifications
You must be signed in to change notification settings - Fork 468
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
coord: Apply schema migrations to builtin tables and views #11741
Conversation
86ddf90
to
dce467d
Compare
@mjibson This PR isn't exactly ready yet, but the changes to storage.rs are done in case you wanted to look. |
This is a good idea, but I think that since we started working on platform we haven't increased the version number. We also won't be able to upgrade from a pre-platform version to the current version. So I don't think that there exists a valid version to upgrade from to test this. EDIT: Maybe we can teach the upgrade tests to use a specific commit hash instead of a version? 594230e added a column to |
Yeah, you can specify a specific docker tag with a git commit. |
We're also (finally) increasing the version numbers again: v0.27.0-alpha.1, v0.27.0-alpha.2, etc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wrote a test using the "old Git revision" approach but unfortunately it will not work out -- the revision is apparently so old that the catalog is not preserved when attempting to upgrade from it ...
I will have to defer adding a test to CI until a future specific migration happens between two tagged and supported releases. At that time I will be able to implement the "id-of-the-object-has-increased" idea.
I have also added a checkbox to the Epic around adding a test that generally exercises all builtin database objects by creating a materialized view on top of them and making sure the view is readable post-upgrade. Thanks a lot for this idea too.
Thanks for the help @philip-stoev! I had an idea this morning. I can open a PR that adds one of the pg_catalog tables but omit a column. Then follow it up with a PR that adds in the missing column. We could then use those two commits for testing purposes. |
@philip-stoev Once these two PRs pass CI, I think if we merge them back to back it's OK that we don't have a proper migration. Then we could use those for your tests. Do you think that would work? |
@jkosh44 do not merge them just yet -- once their containers arrive in docker hub I will be able to give it a try without merging them to main. Please give me until tomorrow. |
Awesome! No rush, I'll hold off on merging until you let me know. Also if you send me the branch, I can try experimenting. |
I was able to construct a test that seems to do the job. The materialized view created on top of the table that is being migrated survives the migration. Please feel free to push it if you think it is good enough:
|
The test as pasted upgrades to |
…ltin-schema � Conflicts: � src/adapter/src/coord.rs
@mjibson This has a test now which is passing, if you want to re-review whenever you have time. |
test/cluster/mzcompose.py
Outdated
# "test-cluster", | ||
# "test-github-12251", | ||
# "test-remote-storaged", | ||
# "test-drop-default-cluster", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget to comment these back in!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh wow, good catch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
I put this in my queue! Probably won't get to this until this weekend
though, sorry Joe!
…On Wed, Jul 20, 2022 at 1:20 PM Joseph Koshakow ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/adapter/src/coord.rs
<#11741 (comment)>
:
> + // Migrate builtin objects
+ for (compute_id, sink_ids) in builtin_migration_metadata.previous_sink_ids {
+ self.controller
+ .compute_mut(compute_id)
+ .unwrap()
+ .drop_sinks_unvalidated(sink_ids)
+ .await?;
+ }
+ for (compute_id, index_ids) in builtin_migration_metadata.previous_index_ids {
+ self.controller
+ .compute_mut(compute_id)
+ .unwrap()
+ .drop_indexes_unvalidated(index_ids)
+ .await?;
+ }
+ for (compute_id, recorded_view_ids) in builtin_migration_metadata.previous_recorded_view_ids
+ {
+ self.controller
+ .compute_mut(compute_id)
+ .unwrap()
+ .drop_sinks_unvalidated(recorded_view_ids.clone())
+ .await?;
+ self.controller
+ .storage_mut()
+ .drop_sources_unvalidated(recorded_view_ids)
+ .await?;
+ }
+ self.controller
+ .storage_mut()
+ .drop_sources_unvalidated(builtin_migration_metadata.previous_source_ids)
+ .await?;
+
I'm not really a big fan of all these "unvalidated" methods, but I'm not
sure what else to do.
—
Reply to this email directly, view it on GitHub
<#11741 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAGXSIF4PAAZMCW7WUJ5KWDVVAYM3ANCNFSM5THQAXXA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
@benesch Did you mean to comment on this? |
GitHub seems to have found a bunch of undelivered email comments overnight and posted them. So I did mean to comment that but ... like two months ago, lol. |
This commit adds the functionality to be able to migrate the schema of
builtin objects. It accomplishes this by dropping all objects that have
changed schema, along with all objects that depend on the original
object. Then it recreates all dropped objects with new GlobalIds.
Previously in the single binary world, schema migrations were
accomplished by restarting the whole system. In the platform world,
each component restarts independently which is why that approach no
longer worked.
Works towards resolving MaterializeInc/database-issues#3332
Motivation
This PR adds a known-desirable feature.
Tips for reviewer
Catalog::transact
forAction::DropItem
was moved entirely toCatalogState::drop_item
. The one change is thatif !id.is_system()
was added tobecause introspection source indexes are not included in
exports
.Testing
Release notes
This PR includes the following user-facing behavior changes:
Dependencies