citus/src/backend/distributed/commands
Onur Tirtir f4242685e3
Add failure handling for CREATE DATABASE commands (#7483)
In preprocess phase, we save the original database name, replace
dbname field of CreatedbStmt with a temporary name (to let Postgres
to create the database with the temporary name locally) and then
we insert a cleanup record for the temporary database name on all
nodes **(\*\*)**.

And in postprocess phase, we first rename the temporary database
back to its original name for local node and then return a list of
distributed DDL jobs i) to create the database with the temporary
name and then ii) to rename it back to its original name on other
nodes. That way, if CREATE DATABASE fails on any of the nodes, the
temporary database will be cleaned up by the cleanup records that
we inserted in preprocess phase and in case of a failure, we won't
leak any databases called as the name that user intended to use for
the database.

Solves the problem documented in
https://github.com/citusdata/citus/issues/7369
for CREATE DATABASE commands.

**(\*\*):** To ensure that we insert cleanup records on all nodes,
with this PR we also start requiring having the coordinator in the
metadata because otherwise we would skip inserting a cleanup record
for the coordinator.
2024-02-23 17:02:32 +00:00
..
README.md Make enterprise features open source (#6008) 2022-06-16 00:23:46 -07:00
alter_table.c Generate qualified relation name (#7427) 2024-01-22 17:32:49 +03:00
begin.c Sort includes (#7326) 2023-11-23 18:19:54 +01:00
call.c Sort includes (#7326) 2023-11-23 18:19:54 +01:00
cascade_table_operation_for_connected_relations.c Sort includes (#7326) 2023-11-23 18:19:54 +01:00
citus_add_local_table_to_metadata.c Generate qualified relation name (#7427) 2024-01-22 17:32:49 +03:00
citus_global_signal.c Sort includes (#7326) 2023-11-23 18:19:54 +01:00
cluster.c Sort includes (#7326) 2023-11-23 18:19:54 +01:00
collation.c Sort includes (#7326) 2023-11-23 18:19:54 +01:00
comment.c Adds comment on database and role propagation (#7388) 2024-01-18 20:58:44 +03:00
common.c Sort includes (#7326) 2023-11-23 18:19:54 +01:00
create_distributed_table.c Generate qualified relation name (#7427) 2024-01-22 17:32:49 +03:00
database.c Add failure handling for CREATE DATABASE commands (#7483) 2024-02-23 17:02:32 +00:00
dependencies.c Adds comment on database and role propagation (#7388) 2024-01-18 20:58:44 +03:00
distribute_object_ops.c Adds comment on database and role propagation (#7388) 2024-01-18 20:58:44 +03:00
domain.c PG16 compatibility: Resolve compilation issues (#7005) 2023-07-21 14:32:37 +03:00
drop_distributed_table.c Sort includes (#7326) 2023-11-23 18:19:54 +01:00
extension.c Replace more spurious strdups with pstrdups (#7441) 2024-01-23 13:28:26 +01:00
foreign_constraint.c Sort includes (#7326) 2023-11-23 18:19:54 +01:00
foreign_data_wrapper.c Sort includes (#7326) 2023-11-23 18:19:54 +01:00
foreign_server.c Sort includes (#7326) 2023-11-23 18:19:54 +01:00
function.c Adds 2PC distributed commands from other databases (#7203) 2023-12-22 19:19:41 +03:00
grant.c Sort includes (#7326) 2023-11-23 18:19:54 +01:00
index.c Add failure handling for CREATE DATABASE commands (#7483) 2024-02-23 17:02:32 +00:00
index_pg_source.c Fix Semmle errors (#4636) 2021-02-08 18:37:44 +03:00
local_multi_copy.c Sort includes (#7326) 2023-11-23 18:19:54 +01:00
multi_copy.c Create directories and files with pg_file_create_mode and pg_dir_create_mode permissions (#7479) 2024-02-07 12:48:31 +01:00
owned.c Adds REASSIGN OWNED BY propagation (#7319) 2023-12-28 15:15:58 +03:00
policy.c Sort includes (#7326) 2023-11-23 18:19:54 +01:00
publication.c Sort includes (#7326) 2023-11-23 18:19:54 +01:00
rename.c Sort includes (#7326) 2023-11-23 18:19:54 +01:00
role.c Fixes invalid grantor field parsing in grant role propagation (#7451) 2024-02-15 08:27:29 +00:00
schema.c Sort includes (#7326) 2023-11-23 18:19:54 +01:00
schema_based_sharding.c Sort includes (#7326) 2023-11-23 18:19:54 +01:00
seclabel.c Support SECURITY LABEL ON ROLE from any node (#7508) 2024-02-15 20:34:15 +03:00
sequence.c Sort includes (#7326) 2023-11-23 18:19:54 +01:00
statistics.c Sort includes (#7326) 2023-11-23 18:19:54 +01:00
subscription.c Sort includes (#7326) 2023-11-23 18:19:54 +01:00
table.c Sort includes (#7326) 2023-11-23 18:19:54 +01:00
text_search.c Adds comment on database and role propagation (#7388) 2024-01-18 20:58:44 +03:00
trigger.c Sort includes (#7326) 2023-11-23 18:19:54 +01:00
truncate.c Sort includes (#7326) 2023-11-23 18:19:54 +01:00
type.c Sort includes (#7326) 2023-11-23 18:19:54 +01:00
utility_hook.c Add failure handling for CREATE DATABASE commands (#7483) 2024-02-23 17:02:32 +00:00
vacuum.c Sort includes (#7326) 2023-11-23 18:19:54 +01:00
variableset.c Sort includes (#7326) 2023-11-23 18:19:54 +01:00
view.c Generate qualified relation name (#7427) 2024-01-22 17:32:49 +03:00

README.md

Commands

The commands module is modeled after backend/commands from the postgres repository and contains the logic for Citus on how to run these commands on distributed objects. Even though the structure of the directory has some resemblence to its postgres relative, files here are somewhat more fine-grained. This is due to the nature of citus commands that are heavily focused on distributed tables. Instead of having all commands in tablecmds.c they are often moved to files that are named after the command.

File Description
create_distributed_table.c Implementation of UDF's for creating distributed tables
drop_distributed_table.c Implementation for dropping metadata for partitions of distributed tables
extension.c Implementation of CREATE EXTENSION commands for citus specific checks
foreign_constraint.c Implementation of and helper functions for foreign key constraints
grant.c Implementation of GRANT commands for roles/users on relations
index.c Implementation of commands specific to indices on distributed tables
multi_copy.c Implementation of COPY command. There are multiple different copy modes which are described in detail below
policy.c Implementation of CREATE\ALTER POLICY commands.
rename.c Implementation of ALTER ... RENAME ... commands. It implements the renaming of applicable objects, otherwise provides the user with a warning
schema.c
sequence.c Implementation of CREATE/ALTER SEQUENCE commands. Primarily checks correctness of sequence statements as they are not propagated to the worker nodes
table.c
transmit.c Implementation of COPY commands with format transmit set in the options. This format is used to transfer files from one node to another node
truncate.c Implementation of TRUNCATE commands on distributed tables
utility_hook.c This is the entry point from postgres into the commands module of citus. It contains the implementation that gets registered in postgres' ProcessUtility_hook callback to extends the functionality of the original ProcessUtility. This code is used to route the incoming commands to their respective implementation in Citus
vacuum.c Implementation of VACUUM commands on distributed tables

COPY

The copy command is overloaded for a couple of use-cases specific to citus. The syntax of the command stays the same, however the implementation might slightly differ from the stock implementation. The overloading is mostly done via extra options that Citus uses to indicate how to operate the copy. The options used are described below.

FORMAT transmit

Implemented in transmit.c

TODO: to be written by someone with enough knowledge to write how, when and why it is used.

FORMAT result

Implemented in multi_copy.c

TODO: to be written by someone with enough knowledge to write how, when and why it is used.