Environment
- YugabyteDB Anywhere - 2.20.2
- YugabyteDB - 2.14 and above
Issue
YBA restore(using YBA Backup) fails with error like below:
ImportTableEntry: YSQL table not found: test_table_temp_old
(for a table named test_table)
Resolution
Overview
An ADD/DROP primary key or ALTER TYPE operation on an older version of YBDB renames the table to “<table_name>_temp_old”, creates a new table, and then drops the old table.
If this operation fails after the rename, the PG metadata will be rolled back; however, the associated DocDB table will have the name “<table_name>_temp_old”.
2024.1 YBDB release has the new feature for DDL Atomicity, that will reduce the chance of these divergences.
Workaround Steps:
1. If it's possible to take another backup, Execute:
ALTER TABLE test_table RENAME TO test_table_temp_old;
ALTER TABLE test_table_temp RENAME TO test_table;
This will rename the DocDB table to "test_table".
Now take another backup, and the restore should succeed.
OR
2. If it's not possible to take another backup, Modify the ysql_dump script from the existing backup by changing all references to test_table with test_table_temp_old. Then retry the restore operation. (Need to download the schema file from the YBA backup, modify it and upload it back to the backup. Post this, the restore will work fine.)
Example Commands to retrieve the metadata from the backup:
mkdir -p /tmp/md
<path>/controller/bin/yb-controller-cli download_md --cloud_type google --bucket bucket_name --cloud_dir univ-<univ_id>/ybc_backup-075de6bf165948388d06fe64d96914c9/incremental/2024-05-10T02:49:48/database_name_ad96eda849eb4013ba0d79614ec0e286 --local_dir /tmp/md
Edit the Schema dump (database_name_ad96eda849eb4013ba0d79614ec0e286) to rename the test_table CREATE TABLE to test_table_temp_old.
Command used to upload the metadata from the backup:
<path>/controller/bin/yb-controller-cli upload_md --cloud_type google --bucket bucket_name --cloud_dir univ-<univ_id>/ybc_backup-075de6bf165948388d06fe64d96914c9/incremental/2024-05-10T02:49:48/database_name_ad96eda849eb4013ba0d79614ec0e286 --local_dir /tmp/md
Additional Information
GitHub issue for the DDB Atomicity Feature https://github.com/yugabyte/yugabyte-db/issues/13358
Comments
0 comments
Please sign in to leave a comment.