-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BACKPORT 2024.1][#22802] YSQL: Avoid renaming DocDb tables during le…
…gacy rewrite Summary: As part of legacy table rewrite operations that clone the table, the old table is renamed to <table_name>_temp_old. Without DDL atomicity, if the operation fails at any point after the rename, the PG metadata is rolled back (relname is rolled back to <table_name>), but the DocDB table name is still <table_name>_temp_old. Note: the same rename is also done for the table's indexes. These renamed DocDB tables cause issues with backup/restore as the restore operation relies on table names. We can avoid these issues by avoiding the DocDB level renames altogether, as the old tables are going to be dropped anyway. Now, after a failed ADD/DROP pkey, ALTER TYPE operation (using the legacy rewrite), the DocDB table will no longer be left with the name <table_name>_temp_old. However, there will now be two DocDB tables with the same table name after a failed legacy rewrite operation. The async transaction cleanup task on master will lookup the entry for this orphaned table in pg_class (using the pg oid in the DocDB table id), and will drop the table upon finding that it doesn't exist. If, for some reason, the orphaned table is not cleaned up, or if a back up is taken before the cleanup happens, the backup code will simply ignore this orphaned table. Specifically, RepackSnapshotsForBackup will not find the pg schema name metadata for this table, and will simply ignore it. Therefore, there will be no ambiguity on restore side (which relies on the table names). Jira: DB-11703 Original commit: c47b2d9 / D35943 Test Plan: On an alma8 release build: ./yb_build.sh release --cxx-test tools_yb-backup-cross-feature-test --gtest_filter YBBackupTest.TestBackupWithFailedLegacyRewrite -n 100 Reviewers: myang Reviewed By: myang Subscribers: ybase, yql Tags: #jenkins-ready Differential Revision: https://phorge.dev.yugabyte.com/D36219
- Loading branch information
1 parent
abdb781
commit 277bd38
Showing
4 changed files
with
55 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters