-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Add primary key to selectors table #10586
Conversation
Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: zhangbutao.
|
@@ -69,6 +69,7 @@ | |||
List<SelectorRecord> getSelectors(@Bind("environment") String environment); | |||
|
|||
@SqlUpdate("CREATE TABLE IF NOT EXISTS selectors (\n" + | |||
" id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,\n" + |
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 think we should use https://flywaydb.org/ to handle the schema changes. Also this is very vendor specific syntax. I am not sure what RDBMS vendors we support here.
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.
See in-flight PR #9812 for Flyway.
I beleive we plan to support Postgres, MySQL and Oracle only.
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 have changed the syntax of primary key to make more generic. I don't know if it's a reasonable fix here, but i see resource_groups table also has similar primary key syntax.
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please submit the signed CLA to [email protected]. For more information, see https://github.com/trinodb/cla. |
@@ -1,10 +1,12 @@ | |||
CREATE TABLE IF NOT EXISTS selectors ( | |||
id BIGINT NOT NULL AUTO_INCREMENT, |
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 believe these files should never be mutated. @hashhar can we have a test?
For example use previous version to populate the DB state and use current to update it?
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.
Firstly, these tables will not be changed after trino first startup unless updated artificially. And if we update table by adding primary key, mysql will automatically update the historical rows with adding the primary key value. So , there is nothing effect on previous version DB state.
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.
The whole https://github.com/trinodb/trino/tree/master/plugin/trino-resource-group-managers/src/main/resources/db/migration/mysql is used with Flyway, it's a reply-log of DB schema changes, and so individual changes shouldn't change.
@hashhar does Flyway record checksum of the changes files, would it detect an accidental modification?
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.
does Flyway record checksum of the changes files, would it detect an accidental modification?
It does.
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.
What happens then?
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.
does Flyway record checksum of the changes files, would it detect an accidental modification?
It does.
@aalbu we need a test ensuring no accidental modifications are done.
Could be as benign as someone reformatting large number of files, or Flyway changes checksum result in a corner case. #10586 (comment) would catch any such issue, let's plan on doing it.
cc @hashhar
@zhangbutao Rebase on current master to include changes merged in #9812. Add all migrations as new files (and maybe for all supported databases - wdyt @nineinchnick @aalbu ), also notice that now only Flyway is used for managing database state so you don't need the changes to the Jdbi objects. Separate we'll look into adding tests which ensure that changes to older migrations are caught. |
👍
do we still need those jdbi annotations?
@nineinchnick @aalbu @hashhar do we have an issue? |
|
Agreed, we should mirror the changes for all supported databases. |
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please submit the signed CLA to [email protected]. For more information, see https://github.com/trinodb/cla. |
I have added new migrations files for all supported databases and no changes to the Jdbi objects. What else need I do? I have sent cla email to [email protected] , please check. thx |
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.
nit: add newlines to all migrations.
LGTM otherwise.
...oup-managers/src/main/resources/db/migration/postgresql/V5__add_primary_key_to_selectors.sql
Outdated
Show resolved
Hide resolved
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please submit the signed CLA to [email protected]. For more information, see https://github.com/trinodb/cla. |
The cla-bot has been summoned, and re-checked this pull request! |
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please submit the signed CLA to [email protected]. For more information, see https://github.com/trinodb/cla. |
@cla-bot check |
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please submit the signed CLA to [email protected]. For more information, see https://github.com/trinodb/cla. |
The cla-bot has been summoned, and re-checked this pull request! |
Gentle ping. Can someone merge this request? |
Some databases like Percona XtraDB Cluster prohibit inserts into tables without primary keys. This change also makes this table consistent with other tables in the resource groups database.
Percona-XtraDB-Cluster prohibit insert on table without primary key. And if adding primary key also help to select specific row.
Fixes #10585
Documentation
(x) No documentation is needed.
Release notes
(x) No release notes entries required.