master_remove_distributed_table_metadata_from_workers doesn't take an affect until xact is committed
- Dominant language
- C
- Stars
- 12.8k
- Forks
- 794
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 31
Description
As far as I see, this udf doesn't take an affect until the transaction is committed.
I see that we use `master_remove_distributed_table_metadata_from_workers` to drop citus tables and their metadata from mx-worker nodes during version updates (in order to recreate them later).
In that sense, it might not be much of a problem but it's actually a user facing udf as well.
For this reason, we should at least prevent execution of `master_remove_distributed_table_metadata_from_workers` in xact blocks for convenience.
```sql
BEGIN;
SELECT master_remove_distributed_table_metadata_from_workers('ref_table'::regclass::oid, 'public', 'ref_table');
SELECT run_command_on_workers(
$$
SELECT count(*) from pg_dist_partition where logicalrelid='ref_table'::regclass;
$$);
run_command_on_workers
------------------------------------------------------------------------------
(localhost,9701,t,1)
(localhost,9702,t,1)
(2 rows)
COMMIT;
-- workers error out after xact is committed as we drop the tables as well, that is ok.
SELECT run_command_on_workers(
$$
SELECT count(*) from pg_dist_partition where logicalrelid='ref_table'::regclass;
$$);
run_command_on_workers
------------------------------------------------------------------------------
(localhost,9701,f,"ERROR: relation ""ref_table"" does not exist")
(localhost,9702,f,"ERROR: relation ""ref_table"" does not exist")
(2 rows)
```
Contributor guide
Assessment
This issue has not been assessed yet.