Skip to content

Commit

Permalink
[BACKPORT 2.20][#24160] docdb: Remove table name equality check in re…
Browse files Browse the repository at this point in the history
…store path

Summary:
Original commit: d6210df / 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
  • Loading branch information
SrivastavaAnubhav committed Oct 7, 2024
1 parent 3698da9 commit c241301
Showing 1 changed file with 1 addition and 17 deletions.
18 changes: 1 addition & 17 deletions src/yb/tablet/tablet_metadata.cc
Original file line number Diff line number Diff line change
Expand Up @@ -514,25 +514,9 @@ Result<TableInfo*> 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,
Expand Down

0 comments on commit c241301

Please sign in to comment.