-
Notifications
You must be signed in to change notification settings - Fork 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
[backup][YCQL] Incorrect column-ids in restored YCQL table if original table was altered. #5958
Comments
Actually the backup is correct and all data is available. The bug is in restore-step.
Manual changes:
NOTE: the renaming workaround works only if the same column types were used. |
Issue is the source code:
use |
Workaround for a case when different types were used.
Original table (b.t2):
Restore the table from the backup (into b2.t2), and change the columns:
Create a new backup of the table b2.t2 & restore it back into the table b3.t2.
|
…original table was altered. Summary: Before the fix `CatalogManager::CreateTable()` always sets column ids into 0,1,2,3.. Due to ALTER TABLE statements columns can be added/removed. (E.g. into 0,2,3 after `ALTER TABLE t DROP c1;`) But on the backup-restore step RecreateTable() calls CreateTable(), which sets the column ids into '0,1,2' instead of using existing in the backup ids. As result the restored table schema references to wrong columns. The fix include the following code changes: - In `CatalogManager::RecreateTable()`: removed code for column ids clean-up. - In `ValidateCreateTableSchema()`: added ability to allow incoming column ids. - In `CatalogManager::CreateTable()`: the table schema must use old (provided by the caller) column ids. Test Plan: ybd --java-test org.yb.cql.TestYbBackup#testAlteredYCQLTableBackup Reviewers: mihnea, mikhail, neil, bogdan Reviewed By: bogdan Subscribers: kannan, yql Differential Revision: https://phabricator.dev.yugabyte.com/D9608
Fixed by the commit above: fa1ba0a |
…tored table if original table was altered. Summary: Before the fix `CatalogManager::CreateTable()` always sets column ids into 0,1,2,3.. Due to ALTER TABLE statements columns can be added/removed. (E.g. into 0,2,3 after `ALTER TABLE t DROP c1;`) But on the backup-restore step RecreateTable() calls CreateTable(), which sets the column ids into '0,1,2' instead of using existing in the backup ids. As result the restored table schema references to wrong columns. The fix include the following code changes: - In `CatalogManager::RecreateTable()`: removed code for column ids clean-up. - In `ValidateCreateTableSchema()`: added ability to allow incoming column ids. - In `CatalogManager::CreateTable()`: the table schema must use old (provided by the caller) column ids. Original diff: D9608 / fa1ba0a Test Plan: ybd --java-test org.yb.cql.TestYbBackup#testAlteredYCQLTableBackup Jenkins: rebase: 2.2, hot Reviewers: mihnea, neil, bogdan Reviewed By: bogdan Subscribers: yql Differential Revision: https://phabricator.dev.yugabyte.com/D10346
Currently CatalogManager::CreateTable() sets column ids into 0,1,2,3..
Due to ALTER TABLE statements columns can be added/removed. (E.g. into 0,2,3 after
ALTER TABLE t DROP col1;
)But on the backup-restore step
RecreateTable()
callsCreateTable()
, which sets the column ids into '0,1,2' instead of using existing in the backup ids.As result the restored table schema references to wrong columns.
Example. Source table:
Restored table:
The text was updated successfully, but these errors were encountered: