DESCRIPTION: Adds support for issuing `CREATE`/`DROP` DATABASE commands from worker nodes With this commit, we allow issuing CREATE / DROP DATABASE commands from worker nodes too. As in #7278, this is not allowed when the coordinator is not added to metadata because we don't ever sync metadata changes to coordinator when adding coordinator to the metadata via `SELECT citus_set_coordinator_host('<hostname>')`, or equivalently, via `SELECT citus_add_node(<coordinator_node_name>, <coordinator_node_port>, 0)`. We serialize database management commands by acquiring a Citus specific advisory lock on the first primary worker node if there are any workers in the cluster. As opposed to what we've done in https://github.com/citusdata/citus/pull/7278 for role management commands, we try to avoid from running into distributed deadlocks as much as possible. This is because, while distributed deadlocks that can happen around role management commands can be detected by Citus, this is not the case for database management commands because most of them cannot be run inside in a transaction block. In that case, Citus cannot even detect the distributed deadlock because the command is not part of a distributed transaction at all, then the command execution might not return the control back to the user for an indefinite amount of time. |
||
---|---|---|
.. | ||
README.md | ||
alter_table.c | ||
begin.c | ||
call.c | ||
cascade_table_operation_for_connected_relations.c | ||
citus_add_local_table_to_metadata.c | ||
citus_global_signal.c | ||
cluster.c | ||
collation.c | ||
common.c | ||
create_distributed_table.c | ||
database.c | ||
dependencies.c | ||
distribute_object_ops.c | ||
domain.c | ||
drop_distributed_table.c | ||
extension.c | ||
foreign_constraint.c | ||
foreign_data_wrapper.c | ||
foreign_server.c | ||
function.c | ||
grant.c | ||
index.c | ||
index_pg_source.c | ||
local_multi_copy.c | ||
multi_copy.c | ||
owned.c | ||
policy.c | ||
publication.c | ||
rename.c | ||
role.c | ||
schema.c | ||
schema_based_sharding.c | ||
seclabel.c | ||
sequence.c | ||
statistics.c | ||
subscription.c | ||
table.c | ||
text_search.c | ||
trigger.c | ||
truncate.c | ||
type.c | ||
utility_hook.c | ||
vacuum.c | ||
variableset.c | ||
view.c |
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.