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

[YSQL][backup] Failed backup if the restored table was deleted before the restoration. #5274

Closed
OlegLoginov opened this issue Jul 30, 2020 · 1 comment
Assignees
Labels
area/ysql Yugabyte SQL (YSQL) kind/bug This issue is a bug

Comments

@OlegLoginov
Copy link
Contributor

OlegLoginov commented Jul 30, 2020

The case:

  • Create backup for ysql.yugabyte (table T1)
  • Delete the table T1
  • Restore backup back into yugabyte DB - successfully recreated T1
    ImportSnapshot failed due to 2 tables with the same name (1 table - new, second - deleted):
    Unable to import snapshot meta file /tmp/yb_backup_wkcfvtmztglztbhd/SnapshotInfoPB: Found 2 YSQL tables with the same name: ttt - 000030a9000030008000000000004000, 000030a9000030008000000000004100: SNAPSHOT_FAILED (master error 23)

The command yb-admin dump_masters_state console shows 2 tables with the same name - one table is in DELETED state, and another one - RUNNING:

000030a9000030008000000000004000:
  namespace name: "yugabyte"
  name: "ttt"
  [not present in by-name map]
  metadata: name: "ttt"   .......... state: DELETED state_msg: "Deleted with tablets at 2020-07-30 18:20:55 MSK"
000030a9000030008000000000004100:
  namespace name: "yugabyte"
  name: "ttt"
  [not present in by-name map]
  metadata: name: "ttt" ............. state: RUNNING 
@OlegLoginov OlegLoginov added kind/bug This issue is a bug area/ysql Yugabyte SQL (YSQL) labels Jul 30, 2020
@OlegLoginov OlegLoginov self-assigned this Jul 30, 2020
OlegLoginov added a commit that referenced this issue Aug 3, 2020
…e the restoration.

Summary:
YSQL table is restored via external tool `ysqlsh` run. CatalogManager::ImportSnapshot() is searching the recreated table by name.
The function must find only one such table.

If the table was deleted before the table recreating, so CatalogManager has 2 tables with the same name: one table (new) is in RUNNING state, the second table is in DELETED state.
The fix must skip DELETED tables to prevent CatalogManager::ImportSnapshot() failure with error: `Found 2 YSQL tables with the same name`.

Test Plan:
ybd --cxx-test yb-backup-test_ent --gtest_filter YBBackupTest.TestYSQLKeyspaceBackup
ybd --cxx-test yb-backup-test_ent --gtest_filter YBBackupTest.TestYSQLKeyspaceBackupWithDropTable

Reviewers: nicolas, bogdan

Reviewed By: bogdan

Subscribers: kannan, yql

Differential Revision: https://phabricator.dev.yugabyte.com/D9063
@OlegLoginov
Copy link
Contributor Author

Fixed by the commit above.

OlegLoginov added a commit that referenced this issue Aug 17, 2020
… was deleted before the restoration.

Summary:
Original fix: a32689f

YSQL table is restored via external tool `ysqlsh` run. CatalogManager::ImportSnapshot() is searching the recreated table by name.
The function must find only one such table.

If the table was deleted before the table recreating, so CatalogManager has 2 tables with the same name: one table (new) is in RUNNING state, the second table is in DELETED state.
The fix must skip DELETED tables to prevent CatalogManager::ImportSnapshot() failure with error: `Found 2 YSQL tables with the same name`.

Test Plan:
ybd --cxx-test yb-backup-test_ent --gtest_filter YBBackupTest.TestYSQLKeyspaceBackup
ybd --cxx-test yb-backup-test_ent --gtest_filter YBBackupTest.TestYSQLKeyspaceBackupWithDropTable
Jenkins: rebase: 2.2

Reviewers: nicolas, bogdan, alex

Reviewed By: alex

Subscribers: alex, yql, kannan

Differential Revision: https://phabricator.dev.yugabyte.com/D9163
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ysql Yugabyte SQL (YSQL) kind/bug This issue is a bug
Projects
None yet
Development

No branches or pull requests

1 participant