Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#23230] [DB Clone][YSQL]: Fix Cloning to a time before drop table in…
… case of colocated databases Summary: Prior to this diff, clone was failing when we were cloning to a time before a drop table operation happened on the source database. The problem is demonstrated in the colocated case only and shouldn't be mixed with D35178. The root cause of the problem is that ysql_dump is unable to set the tablegroup_id correctly in the sql script. More specifically in the following snippet (notice the 0 which is a wrong default value): ``` -- For YB colocation backup, must preserve implicit tablegroup pg_yb_tablegroup oid SELECT pg_catalog.binary_upgrade_set_next_tablegroup_oid('0'::pg_catalog.oid); ``` This is because calling `yb_table_properties()` on the dropped table will not set the tablegroup_id in the response. As part of executing `yb_table_properties()`, `GetTableSchema` is called which in turn doesn't set the tablegroup_id properly if the requested table is a dropped one. The problem is that the tablegroup manager will not have an entry of the dropped table inside its inmemory maps and thus the tablegroup manager will return a nullptr when asked to get the tablegroup of the dropped table using `FindByTable`. The diff fixes the issue by returning the tablegroup_id using the **colocation parent table id** rather than asking the tablegroup manager for the tablegroup_id. The idea is that we can always infer the tablegroup_id from the parent table as all the colocated tables share the same tablegroup_id. We also guarantee that the colocated database corresponding to the returned `tablegroup_id` should still be there as the table is guaranteed not to be in a deleted state (There is a previous check in `GetTableSchemInternal` for that). Test Plan: Switched the test CloneAfterDropTable to a parametrized test where the parameter tests both colocation and non-colocation cases. ./yb_build.sh --cxx-test integration-tests_minicluster-snapshot-test --gtest_filter Colocation/PgCloneTestParam.CloneAfterDropTable/1 Reviewers: asrivastava, zdrudi Reviewed By: zdrudi Subscribers: ybase, slingam Differential Revision: https://phorge.dev.yugabyte.com/D36702
- Loading branch information