From c2413016e05534cedc74dfde093b8b049fc0075f Mon Sep 17 00:00:00 2001 From: Anubhav Srivastava Date: Wed, 2 Oct 2024 10:14:57 -0700 Subject: [PATCH] [BACKPORT 2.20][#24160] docdb: Remove table name equality check in restore path Summary: Original commit: d6210df158efe504b40e7d08807c872f8ff7a8e2 / D38512 D22774 introduced a check that the name of the table being restored and the name of the table in the snapshot are the same. This is not true for PITR / clone if the table has been renamed since the snapshot. This diff removes that check. This might cause backups that were created with partial indexes and before diff D23486 to restore with an incorrect schema if there is also a colocation id collision between the created table and a table in the snapshot. Jira: DB-13047 Test Plan: Set `ysql_enable_packed_row_for_colocated_table = true` and run: `./yb_build.sh release --cxx-test tools_yb-admin-snapshot-schedule-test --gtest_filter ColocationAndRestoreType/YbAdminSnapshotScheduleTestWithYsqlColocationRestoreParam.PgsqlRenameTable/4` The test previously failed because we were skipping schema merging. Reviewers: yguan, zdrudi Reviewed By: zdrudi Subscribers: ybase Differential Revision: https://phorge.dev.yugabyte.com/D38636 --- src/yb/tablet/tablet_metadata.cc | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/src/yb/tablet/tablet_metadata.cc b/src/yb/tablet/tablet_metadata.cc index 96f82b374fd7..2edb6bd54286 100644 --- a/src/yb/tablet/tablet_metadata.cc +++ b/src/yb/tablet/tablet_metadata.cc @@ -514,25 +514,9 @@ Result KvStoreInfo::FindMatchingTable( snapshot_table.schema().colocated_table_id().colocation_id()); return nullptr; } - // Sanity check names and schemas. Because colocation ids are chosen at restore time for colocated - // partitioned tables in backups made prior to 29681f579760703663cdcbd2abbfe4c9eb6e533c yb-master - // may have randomly chosen a colocation id for a partitioned table that matches the colocation id - // of a partitioned table in the snapshot with an incompatible schema. - auto& local_table = table_it->second; - if (local_table->table_name != snapshot_table.table_name() || - (snapshot_table.schema().has_pgschema_name() && local_table->schema().has_pgschema_name() && - snapshot_table.schema().pgschema_name() != local_table->schema().SchemaName())) { - LOG(WARNING) << Format( - "Skipping schema merging for snapshot table $0.$1 due to mismatch with local " - "table names, local table is $2.$3", - snapshot_table.schema().pgschema_name(), - snapshot_table.table_name(), - local_table->schema().SchemaName(), - local_table->table_name); - return nullptr; - } // Sanity check: the same table should have same TableInfo in both tables and colocation_to_table. + auto& local_table = table_it->second; auto tables_it = tables.find(local_table->table_id); RSTATUS_DCHECK( tables_it != tables.end(), NotFound,