-
Notifications
You must be signed in to change notification settings - Fork 1.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
[Phase 2][YSQL][Colocation] yb-admin create_database_snapshot can't deal with tablegroups #11632
Comments
Also seeing this with LST trying to test backup/restore, disabling tablegroups for LST with backup/restore scenario. |
Backup/restore of a database containing tablegroup fails due to the failure of
|
@def- Do you still have the logs? When you disable tablegroups for LST, do you still enable colocated databases? |
No colocation used currently, but this failure happened with tablegroups (as a consequence I disabled tablegroups in backup/restore tests). Logs should still be available at https://portal.dev.yugabyte.com/universes/edaf84f8-508e-4fc0-840f-6b91d37ad21c |
I think @msun07 is fixing it as part of https://phabricator.dev.yugabyte.com/D19398 |
@sanketkedia @msun07 I'm also working on this including the whole backup process (create_database_snapshot, import_snapshot, platform backup script change): https://phabricator.dev.yugabyte.com/D18820, not from PITR perspective though. |
Summary: This diff supports backup and restore for tablegroup. Problem: Tablegroup parent name is in the format: <tablegroup_id>.tablegroup.parent.tablename, and its uuid is in the format: <tablegroup_id>.tablegroup.parent.uuid. In general, for a restore process, the table matching during `import_snapshot` step is based on table uuid or table name. Either one of them should remain the same, or we need a way to calculate the table's new name or new id on a new cluster based on the old table name or id stored in SnapshotInfoPB. Before this diff, it is hard to match a tablegroup parent table during `import_snapshot` because a tablegroup oid generated on postgres side on a new cluster can be different from the oid on the old cluster. Consider the following example: ``` CREATE TABLE tbl (a INT); -- OID: 16384 CREATE TABLEGROUP tg1; -- OID: 16387 CREATE TABLE tbl2 (a INT) TABLEGROUP tg1; -- OID: 16388 ``` Recreating these objects using `ysql_dump` follows the order: ``` CREATE TABLEGROUP tg1; -- OID: 16384 CREATE TABLE tbl (a INT); -- OID: 16385 CREATE TABLE tbl2 (a INT) TABLEGROUP tg1; -- OID: 16388 ``` With the tabelgroup parent table name/uuid format, we cannot match the parent table based on its name/uuid, and cannot calculate parent table name/uuid on the new cluster. To address the overall backup problem, major changes in this diff are: - Preserve tablegroup oid in `ysql_dump`. Use the PG binary upgrade style approach to preserve tablegroup oid so that tablegroup oid of a tablegroup remains the same on a new cluster. - Add `yb-admin import_snapshot` support for tablegroup parent table. Calculate tablegroup parent table uuid based on old tablegroup parent table uuid from old cluster. The logic is: (1) old_tablegroup_parent_table_uuid = function(old_namespace_oid, old_tablegroup_oid) (2) We know the uuid matching between the old namespace and the new namespace from an earlier step in `import_snapshot`, and tablegroup oid remains the same. (3) So new_tablegroup_parent_table_uuid = function(new_namespace_oid, old_tablegroup_oid) Sample output of import_snapshot for the above exmaple: ``` Read snapshot meta file Importing snapshot 40b4e757-797d-4ea2-be80-fc51810f92dc (COMPLETE) Target imported YSQL database name: yugabyte YSQL database being imported: yugabyte Table type: table Table being imported: yugabyte.tbl Table type: colocated table Colocated table being imported: yugabyte.000033e8000030008000000000004003.tablegroup.parent.tablename Table type: colocated table Colocated table being imported: yugabyte.tbl2 Successfully applied snapshot. Object Old ID New ID Keyspace 000033e8000030008000000000000000 000033e8000030008000000000000000 Table 000033e8000030008000000000004000 000033e8000030008000000000004000 Tablet 0 e9746f31b49d45de9ecbf3f78d3d4296 a9a5da1c2c274801b5e4d7bbe248cebc Tablet 1 c8ded40dbe2c4d55bdb7b2c499639071 3a495f69527245b08b894a244a7ccd58 Keyspace 000033e8000030008000000000000000 000033e8000030008000000000000000 ParentColocatedTable 000033e8000030008000000000004003.tablegroup.parent.uuid 000033e8000030008000000000004003.tablegroup.parent.uuid Tablet 0 37e5ee5686194284956b9aeafe439767 186254847ce8454aa1371056f58da796 Keyspace 000033e8000030008000000000000000 000033e8000030008000000000000000 ColocatedTable 000033e8000030008000000000004004 000033e8000030008000000000004001 Snapshot 40b4e757-797d-4ea2-be80-fc51810f92dc aee3464b-34f9-480c-b7b8-367426dfbec8 ``` - Add tablegroup handling in `yb_backup.py`. In yb_backup.py, add support to parse `import_snapshot` output having tablegroup parent table so that snapshot directories can be downloaded correctly for tablegroup parent table. Test Plan: ./yb_build.sh --java-test 'org.yb.pgsql.TestYsqlDump' ./yb_build.sh --java-test 'org.yb.pgsql.TestYbBackup#testTablegroup' ./yb_build.sh --java-test 'org.yb.pgsql.TestYbBackup#testMultipleTablegroups' Reviewers: mihnea, jhe, msun, myang, alex, oleg, tverona Reviewed By: alex, oleg, tverona Subscribers: zdrudi, jenkins-bot, yugaware, yql, bogdan Differential Revision: https://phabricator.dev.yugabyte.com/D18820
Summary: This diff supports backup and restore for tablegroup. Problem: Tablegroup parent name is in the format: <tablegroup_id>.tablegroup.parent.tablename, and its uuid is in the format: <tablegroup_id>.tablegroup.parent.uuid. In general, for a restore process, the table matching during `import_snapshot` step is based on table uuid or table name. Either one of them should remain the same, or we need a way to calculate the table's new name or new id on a new cluster based on the old table name or id stored in SnapshotInfoPB. Before this diff, it is hard to match a tablegroup parent table during `import_snapshot` because a tablegroup oid generated on postgres side on a new cluster can be different from the oid on the old cluster. Consider the following example: ``` CREATE TABLE tbl (a INT); -- OID: 16384 CREATE TABLEGROUP tg1; -- OID: 16387 CREATE TABLE tbl2 (a INT) TABLEGROUP tg1; -- OID: 16388 ``` Recreating these objects using `ysql_dump` follows the order: ``` CREATE TABLEGROUP tg1; -- OID: 16384 CREATE TABLE tbl (a INT); -- OID: 16385 CREATE TABLE tbl2 (a INT) TABLEGROUP tg1; -- OID: 16388 ``` With the tabelgroup parent table name/uuid format, we cannot match the parent table based on its name/uuid, and cannot calculate parent table name/uuid on the new cluster. To address the overall backup problem, major changes in this diff are: - Preserve tablegroup oid in `ysql_dump`. Use the PG binary upgrade style approach to preserve tablegroup oid so that tablegroup oid of a tablegroup remains the same on a new cluster. - Add `yb-admin import_snapshot` support for tablegroup parent table. Calculate tablegroup parent table uuid based on old tablegroup parent table uuid from old cluster. The logic is: (1) old_tablegroup_parent_table_uuid = function(old_namespace_oid, old_tablegroup_oid) (2) We know the uuid matching between the old namespace and the new namespace from an earlier step in `import_snapshot`, and tablegroup oid remains the same. (3) So new_tablegroup_parent_table_uuid = function(new_namespace_oid, old_tablegroup_oid) Sample output of import_snapshot for the above exmaple: ``` Read snapshot meta file Importing snapshot 40b4e757-797d-4ea2-be80-fc51810f92dc (COMPLETE) Target imported YSQL database name: yugabyte YSQL database being imported: yugabyte Table type: table Table being imported: yugabyte.tbl Table type: colocated table Colocated table being imported: yugabyte.000033e8000030008000000000004003.tablegroup.parent.tablename Table type: colocated table Colocated table being imported: yugabyte.tbl2 Successfully applied snapshot. Object Old ID New ID Keyspace 000033e8000030008000000000000000 000033e8000030008000000000000000 Table 000033e8000030008000000000004000 000033e8000030008000000000004000 Tablet 0 e9746f31b49d45de9ecbf3f78d3d4296 a9a5da1c2c274801b5e4d7bbe248cebc Tablet 1 c8ded40dbe2c4d55bdb7b2c499639071 3a495f69527245b08b894a244a7ccd58 Keyspace 000033e8000030008000000000000000 000033e8000030008000000000000000 ParentColocatedTable 000033e8000030008000000000004003.tablegroup.parent.uuid 000033e8000030008000000000004003.tablegroup.parent.uuid Tablet 0 37e5ee5686194284956b9aeafe439767 186254847ce8454aa1371056f58da796 Keyspace 000033e8000030008000000000000000 000033e8000030008000000000000000 ColocatedTable 000033e8000030008000000000004004 000033e8000030008000000000004001 Snapshot 40b4e757-797d-4ea2-be80-fc51810f92dc aee3464b-34f9-480c-b7b8-367426dfbec8 ``` - Add tablegroup handling in `yb_backup.py`. In yb_backup.py, add support to parse `import_snapshot` output having tablegroup parent table so that snapshot directories can be downloaded correctly for tablegroup parent table. Test Plan: ./yb_build.sh --java-test 'org.yb.pgsql.TestYsqlDump' ./yb_build.sh --java-test 'org.yb.pgsql.TestYbBackup#testTablegroup' ./yb_build.sh --java-test 'org.yb.pgsql.TestYbBackup#testMultipleTablegroups' Reviewers: mihnea, jhe, msun, myang, alex, oleg, tverona Reviewed By: alex, oleg, tverona Subscribers: zdrudi, jenkins-bot, yugaware, yql, bogdan Differential Revision: https://phabricator.dev.yugabyte.com/D18820
Jira Link: DB-374
Description
On latest master (1f88fc7):
Now try to take a snapshot:
The text was updated successfully, but these errors were encountered: