-
Notifications
You must be signed in to change notification settings - Fork 695
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support CREATE / DROP database commands from any node #7359
Conversation
d85b211
to
f7f5bdf
Compare
c160615
to
0d51f1b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, we have a strange situation where we can't even detect the deadlock?
select citus_add_node('localhost', 9700, 0);
select run_command_on_all_nodes('alter system set citus.enable_create_database_propagation to on');
select run_command_on_all_nodes('select pg_reload_conf()');
select run_command_on_all_nodes('create database onur');
Or equivalently, can use the following script too in order to get rid of the call made to run_command_on_all_nodes()
:
psql -p 9700 -c "SELECT citus_add_node('localhost', 9700, 0)"
psql -p 9700 -c "SELECT run_command_on_all_nodes('alter system set citus.enable_create_database_propagation to on')"
psql -p 9700 -c "SELECT run_command_on_all_nodes('select pg_reload_conf()')"
dbname="$1"
pids=()
for i in `seq 0 2`; do
psql -p 970${i} -c "create database $dbname" &
pids+=($!)
done
for pid in ${pids[*]}; do
wait $pid
done
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #7359 +/- ##
==========================================
- Coverage 89.61% 89.55% -0.06%
==========================================
Files 278 280 +2
Lines 60204 60303 +99
Branches 7496 7505 +9
==========================================
+ Hits 53953 54007 +54
- Misses 4104 4139 +35
- Partials 2147 2157 +10 |
A good description is needed. AFAIU, Removing coordinator limits the propagation. It should be clearly explained in PR description. |
First of all, deadlock detection code doesn't care about the queries Setting And when this info is not provided, distributed deadlock detector cannot |
257f81b
to
52d9ccf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Improve PR description on SerializeDistributedDDLsOnObjectClass.
- Improve PR description on Support CREATE / DROP database commands from any node #7359 (review).
- Add more tests related to concurrency.
...kend/distributed/sql/udfs/citus_internal_acquire_citus_advisory_object_class_lock/12.2-1.sql
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overal
7a19fe9
to
7a5fb97
Compare
...kend/distributed/sql/udfs/citus_internal_acquire_citus_advisory_object_class_lock/latest.sql
Outdated
Show resolved
Hide resolved
DETAIL: Citus does not propagate CREATE DATABASE command to other nodes | ||
HINT: You can manually create a database and its extensions on other nodes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sidenote: Should we update this hint message to include a hint about citus.enable_create_database_propagation? In any case this would be better to do in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense, let me update this in a separate PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#7408, assigned to @gurkanindibay
d307d3f
to
c029ac8
Compare
5e99f23
to
b760a88
Compare
TODO:
|
b760a88
to
108c559
Compare
c029ac8
to
f67448b
Compare
32a3a9d
to
0403a6d
Compare
0403a6d
to
dccac1f
Compare
ERROR: permission denied to create / rename database | ||
CONTEXT: while executing command on localhost:xxxxx | ||
ALTER DATABASE distributed_db RENAME TO rename_test; | ||
ERROR: permission denied to create / rename database | ||
CONTEXT: while executing command on localhost:xxxxx | ||
DROP DATABASE distributed_db; | ||
ERROR: must be owner of database distributed_db | ||
CONTEXT: while executing command on localhost:xxxxx | ||
ALTER DATABASE distributed_db SET TABLESPACE pg_default; | ||
ERROR: must be owner of database distributed_db | ||
CONTEXT: while executing command on localhost:xxxxx | ||
ALTER DATABASE distributed_db SET timezone TO 'UTC'; | ||
ERROR: must be owner of database distributed_db | ||
CONTEXT: while executing command on localhost:xxxxx | ||
ALTER DATABASE distributed_db RESET timezone; | ||
ERROR: must be owner of database distributed_db | ||
CONTEXT: while executing command on localhost:xxxxx | ||
GRANT ALL ON DATABASE distributed_db TO postgres; | ||
WARNING: no privileges were granted for "distributed_db" | ||
RESET ROLE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super-nit: It would be nice if these errors did not come from another node, but instead the privileges were checked before sending commands there. Now users would get this "confusing" CONTEXT: while executing command on localhost:xxxxx
Probably not important enough to do in this PR. So let's make an issue, seems like a "good first issue".
PS. even when doing this, we'd still want these errors too in case attackers try to call these functions manually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let me quickly fix that in this PR while we're at it
src/test/regress/spec/isolation_database_cmd_from_any_node.spec
Outdated
Show resolved
Hide resolved
src/test/regress/spec/isolation_database_cmd_from_any_node.spec
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from removing (see other comment for details):
case OCLASS_SUBSCRIPTION:
And a few other very minor things I think this is good to merge.
95dd250
to
11feabd
Compare
DESCRIPTION: Adds support for issuing
CREATE
/DROP
DATABASE commands from worker nodesWith 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, viaSELECT 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 #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.