Fixes test errors

pull/7563/head
gurkanindibay 2024-03-18 17:46:29 +03:00
parent 7ad5a2479b
commit ff19400238
3 changed files with 159 additions and 26 deletions

View File

@ -367,9 +367,21 @@ GetNonMainDbDistributeObjectOps(Node *parsetree)
case T_AlterDatabaseSetStmt: case T_AlterDatabaseSetStmt:
{ {
return &Any_AlterDatabaseSet; AlterDatabaseSetStmt *stmt = castNode(AlterDatabaseSetStmt, parsetree);
/*
* We don't try to send the query to the main database if the ALTER
* DATABASE command is for the main database itself, this is a very
* rare case but it's exercised by our test suite.
*/
if (strcmp(stmt->dbname, MainDb) != 0)
{
return &Any_AlterDatabaseSet;
} }
return NULL;
}
#if PG_VERSION_NUM >= PG_VERSION_15 #if PG_VERSION_NUM >= PG_VERSION_15
case T_AlterDatabaseRefreshCollStmt: case T_AlterDatabaseRefreshCollStmt:
{ {

View File

@ -5,23 +5,43 @@ create database altered_database;
reset citus.enable_create_database_propagation; reset citus.enable_create_database_propagation;
\c regression; \c regression;
set citus.enable_create_database_propagation=on; set citus.enable_create_database_propagation=on;
\set alter_db_tablespace :abs_srcdir '/tmp_check/ts3'
CREATE TABLESPACE alter_db_tablespace LOCATION :'alter_db_tablespace';
\c - - - :worker_1_port
\set alter_db_tablespace :abs_srcdir '/tmp_check/ts4'
CREATE TABLESPACE alter_db_tablespace LOCATION :'alter_db_tablespace';
\c - - - :worker_2_port
\set alter_db_tablespace :abs_srcdir '/tmp_check/ts5'
CREATE TABLESPACE alter_db_tablespace LOCATION :'alter_db_tablespace';
\c test_alter_db_from_nonmain_db \c test_alter_db_from_nonmain_db
set citus.log_remote_commands = true; set citus.log_remote_commands = true;
set citus.grep_remote_commands = "%ALTER DATABASE%"; set citus.grep_remote_commands = "%ALTER DATABASE%";
alter database altered_database set tablespace alter_db_tablespace;
NOTICE: issuing ALTER DATABASE altered_database SET TABLESPACE alter_db_tablespace
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
ERROR: operation is not allowed on this node
HINT: Connect to the coordinator and run it again.
CONTEXT: while executing command on localhost:xxxxx
alter database altered_database rename to altered_database_renamed; alter database altered_database rename to altered_database_renamed;
alter database altered_database_renamed rename to altered_database; alter database altered_database_renamed rename to altered_database;
alter database altered_database with alter database altered_database with
ALLOW_CONNECTIONS false ALLOW_CONNECTIONS false
CONNECTION LIMIT 1 CONNECTION LIMIT 1
IS_TEMPLATE true; IS_TEMPLATE true;
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database WITH ALLOW_CONNECTIONS false CONNECTION LIMIT 1 IS_TEMPLATE true;', 'postgres') NOTICE: issuing ALTER DATABASE altered_database WITH ALLOW_CONNECTIONS false CONNECTION LIMIT 1 IS_TEMPLATE true;
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
ERROR: operation is not allowed on this node
HINT: Connect to the coordinator and run it again.
CONTEXT: while executing command on localhost:xxxxx
alter database altered_database with alter database altered_database with
ALLOW_CONNECTIONS true ALLOW_CONNECTIONS true
CONNECTION LIMIT 0 CONNECTION LIMIT 0
IS_TEMPLATE false; IS_TEMPLATE false;
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database WITH ALLOW_CONNECTIONS true CONNECTION LIMIT 0 IS_TEMPLATE false;', 'postgres') NOTICE: issuing ALTER DATABASE altered_database WITH ALLOW_CONNECTIONS true CONNECTION LIMIT 0 IS_TEMPLATE false;
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
ERROR: operation is not allowed on this node
HINT: Connect to the coordinator and run it again.
CONTEXT: while executing command on localhost:xxxxx
\c regression \c regression
create role test_owner_non_main_db; create role test_owner_non_main_db;
\c test_alter_db_from_nonmain_db \c test_alter_db_from_nonmain_db
@ -31,81 +51,162 @@ set citus.enable_create_database_propagation=on;
alter database altered_database owner to test_owner_non_main_db; alter database altered_database owner to test_owner_non_main_db;
alter database altered_database owner to CURRENT_USER; alter database altered_database owner to CURRENT_USER;
alter database altered_database set default_transaction_read_only = true; alter database altered_database set default_transaction_read_only = true;
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database SET default_transaction_read_only = ''true''', 'postgres') NOTICE: issuing ALTER DATABASE altered_database SET default_transaction_read_only = 'true'
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
ERROR: operation is not allowed on this node
HINT: Connect to the coordinator and run it again.
CONTEXT: while executing command on localhost:xxxxx
set default_transaction_read_only = false; set default_transaction_read_only = false;
alter database altered_database set default_transaction_read_only from current; alter database altered_database set default_transaction_read_only from current;
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database SET default_transaction_read_only FROM CURRENT', 'postgres') NOTICE: issuing ALTER DATABASE altered_database SET default_transaction_read_only FROM CURRENT
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
ERROR: operation is not allowed on this node
HINT: Connect to the coordinator and run it again.
CONTEXT: while executing command on localhost:xxxxx
alter database altered_database set default_transaction_read_only to DEFAULT; alter database altered_database set default_transaction_read_only to DEFAULT;
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database SET default_transaction_read_only TO DEFAULT', 'postgres') NOTICE: issuing ALTER DATABASE altered_database SET default_transaction_read_only TO DEFAULT
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
ERROR: operation is not allowed on this node
HINT: Connect to the coordinator and run it again.
CONTEXT: while executing command on localhost:xxxxx
alter database altered_database RESET default_transaction_read_only; alter database altered_database RESET default_transaction_read_only;
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database RESET default_transaction_read_only', 'postgres') NOTICE: issuing ALTER DATABASE altered_database RESET default_transaction_read_only
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
ERROR: operation is not allowed on this node
HINT: Connect to the coordinator and run it again.
CONTEXT: while executing command on localhost:xxxxx
alter database altered_database SET TIME ZONE '-7'; alter database altered_database SET TIME ZONE '-7';
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database SET timezone = ''-7''', 'postgres') NOTICE: issuing ALTER DATABASE altered_database SET timezone = '-7'
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
ERROR: operation is not allowed on this node
HINT: Connect to the coordinator and run it again.
CONTEXT: while executing command on localhost:xxxxx
alter database altered_database set TIME ZONE LOCAL; alter database altered_database set TIME ZONE LOCAL;
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database SET timezone TO DEFAULT', 'postgres') NOTICE: issuing ALTER DATABASE altered_database SET timezone TO DEFAULT
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
ERROR: operation is not allowed on this node
HINT: Connect to the coordinator and run it again.
CONTEXT: while executing command on localhost:xxxxx
alter database altered_database set TIME ZONE DEFAULT; alter database altered_database set TIME ZONE DEFAULT;
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database SET timezone TO DEFAULT', 'postgres') NOTICE: issuing ALTER DATABASE altered_database SET timezone TO DEFAULT
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
ERROR: operation is not allowed on this node
HINT: Connect to the coordinator and run it again.
CONTEXT: while executing command on localhost:xxxxx
alter database altered_database RESET TIME ZONE; alter database altered_database RESET TIME ZONE;
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database RESET timezone', 'postgres') NOTICE: issuing ALTER DATABASE altered_database RESET timezone
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
ERROR: operation is not allowed on this node
HINT: Connect to the coordinator and run it again.
CONTEXT: while executing command on localhost:xxxxx
alter database altered_database SET TIME ZONE INTERVAL '-08:00' HOUR TO MINUTE; alter database altered_database SET TIME ZONE INTERVAL '-08:00' HOUR TO MINUTE;
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database SET TIME ZONE INTERVAL ''@ 8 hours ago''', 'postgres') NOTICE: issuing ALTER DATABASE altered_database SET TIME ZONE INTERVAL '@ 8 hours ago'
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
ERROR: operation is not allowed on this node
HINT: Connect to the coordinator and run it again.
CONTEXT: while executing command on localhost:xxxxx
alter database altered_database RESET TIME ZONE; alter database altered_database RESET TIME ZONE;
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database RESET timezone', 'postgres') NOTICE: issuing ALTER DATABASE altered_database RESET timezone
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
ERROR: operation is not allowed on this node
HINT: Connect to the coordinator and run it again.
CONTEXT: while executing command on localhost:xxxxx
alter database altered_database set default_transaction_isolation = 'serializable'; alter database altered_database set default_transaction_isolation = 'serializable';
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database SET default_transaction_isolation = ''serializable''', 'postgres') NOTICE: issuing ALTER DATABASE altered_database SET default_transaction_isolation = 'serializable'
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
ERROR: operation is not allowed on this node
HINT: Connect to the coordinator and run it again.
CONTEXT: while executing command on localhost:xxxxx
set default_transaction_isolation = 'read committed'; set default_transaction_isolation = 'read committed';
alter database altered_database set default_transaction_isolation from current; alter database altered_database set default_transaction_isolation from current;
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database SET default_transaction_isolation FROM CURRENT', 'postgres') NOTICE: issuing ALTER DATABASE altered_database SET default_transaction_isolation FROM CURRENT
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
ERROR: operation is not allowed on this node
HINT: Connect to the coordinator and run it again.
CONTEXT: while executing command on localhost:xxxxx
alter database altered_database set default_transaction_isolation to DEFAULT; alter database altered_database set default_transaction_isolation to DEFAULT;
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database SET default_transaction_isolation TO DEFAULT', 'postgres') NOTICE: issuing ALTER DATABASE altered_database SET default_transaction_isolation TO DEFAULT
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
ERROR: operation is not allowed on this node
HINT: Connect to the coordinator and run it again.
CONTEXT: while executing command on localhost:xxxxx
alter database altered_database RESET default_transaction_isolation; alter database altered_database RESET default_transaction_isolation;
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database RESET default_transaction_isolation', 'postgres') NOTICE: issuing ALTER DATABASE altered_database RESET default_transaction_isolation
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
ERROR: operation is not allowed on this node
HINT: Connect to the coordinator and run it again.
CONTEXT: while executing command on localhost:xxxxx
alter database altered_database set statement_timeout = 1000; alter database altered_database set statement_timeout = 1000;
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database SET statement_timeout = 1000', 'postgres') NOTICE: issuing ALTER DATABASE altered_database SET statement_timeout = 1000
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
ERROR: operation is not allowed on this node
HINT: Connect to the coordinator and run it again.
CONTEXT: while executing command on localhost:xxxxx
set statement_timeout = 2000; set statement_timeout = 2000;
alter database altered_database set statement_timeout from current; alter database altered_database set statement_timeout from current;
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database SET statement_timeout FROM CURRENT', 'postgres') NOTICE: issuing ALTER DATABASE altered_database SET statement_timeout FROM CURRENT
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
ERROR: operation is not allowed on this node
HINT: Connect to the coordinator and run it again.
CONTEXT: while executing command on localhost:xxxxx
alter database altered_database set statement_timeout to DEFAULT; alter database altered_database set statement_timeout to DEFAULT;
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database SET statement_timeout TO DEFAULT', 'postgres') NOTICE: issuing ALTER DATABASE altered_database SET statement_timeout TO DEFAULT
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
ERROR: operation is not allowed on this node
HINT: Connect to the coordinator and run it again.
CONTEXT: while executing command on localhost:xxxxx
alter database altered_database RESET statement_timeout; alter database altered_database RESET statement_timeout;
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database RESET statement_timeout', 'postgres') NOTICE: issuing ALTER DATABASE altered_database RESET statement_timeout
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
ERROR: operation is not allowed on this node
HINT: Connect to the coordinator and run it again.
CONTEXT: while executing command on localhost:xxxxx
alter database altered_database set lock_timeout = 1201.5; alter database altered_database set lock_timeout = 1201.5;
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database SET lock_timeout = 1201.5', 'postgres') NOTICE: issuing ALTER DATABASE altered_database SET lock_timeout = 1201.5
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
ERROR: operation is not allowed on this node
HINT: Connect to the coordinator and run it again.
CONTEXT: while executing command on localhost:xxxxx
set lock_timeout = 1202.5; set lock_timeout = 1202.5;
alter database altered_database set lock_timeout from current; alter database altered_database set lock_timeout from current;
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database SET lock_timeout FROM CURRENT', 'postgres') NOTICE: issuing ALTER DATABASE altered_database SET lock_timeout FROM CURRENT
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
ERROR: operation is not allowed on this node
HINT: Connect to the coordinator and run it again.
CONTEXT: while executing command on localhost:xxxxx
alter database altered_database set lock_timeout to DEFAULT; alter database altered_database set lock_timeout to DEFAULT;
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database SET lock_timeout TO DEFAULT', 'postgres') NOTICE: issuing ALTER DATABASE altered_database SET lock_timeout TO DEFAULT
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
ERROR: operation is not allowed on this node
HINT: Connect to the coordinator and run it again.
CONTEXT: while executing command on localhost:xxxxx
alter database altered_database RESET lock_timeout; alter database altered_database RESET lock_timeout;
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database RESET lock_timeout', 'postgres') NOTICE: issuing ALTER DATABASE altered_database RESET lock_timeout
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
ERROR: operation is not allowed on this node
HINT: Connect to the coordinator and run it again.
CONTEXT: while executing command on localhost:xxxxx
ALTER DATABASE altered_database RESET ALL; ALTER DATABASE altered_database RESET ALL;
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database RESET ALL', 'postgres') NOTICE: issuing ALTER DATABASE altered_database RESET ALL
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
ERROR: operation is not allowed on this node
HINT: Connect to the coordinator and run it again.
CONTEXT: while executing command on localhost:xxxxx
\c regression \c regression
set citus.enable_create_database_propagation=on; set citus.enable_create_database_propagation=on;
drop database altered_database; drop database altered_database;
drop database test_alter_db_from_nonmain_db; drop database test_alter_db_from_nonmain_db;
reset citus.enable_create_database_propagation; reset citus.enable_create_database_propagation;
drop role test_owner_non_main_db; drop role test_owner_non_main_db;
SELECT result FROM run_command_on_all_nodes(
$$
drop tablespace alter_db_tablespace
$$
);
result
---------------------------------------------------------------------
DROP TABLESPACE
DROP TABLESPACE
DROP TABLESPACE
(3 rows)

View File

@ -5,9 +5,23 @@ create database altered_database;
reset citus.enable_create_database_propagation; reset citus.enable_create_database_propagation;
\c regression; \c regression;
set citus.enable_create_database_propagation=on; set citus.enable_create_database_propagation=on;
\set alter_db_tablespace :abs_srcdir '/tmp_check/ts3'
CREATE TABLESPACE alter_db_tablespace LOCATION :'alter_db_tablespace';
\c - - - :worker_1_port
\set alter_db_tablespace :abs_srcdir '/tmp_check/ts4'
CREATE TABLESPACE alter_db_tablespace LOCATION :'alter_db_tablespace';
\c - - - :worker_2_port
\set alter_db_tablespace :abs_srcdir '/tmp_check/ts5'
CREATE TABLESPACE alter_db_tablespace LOCATION :'alter_db_tablespace';
\c test_alter_db_from_nonmain_db \c test_alter_db_from_nonmain_db
set citus.log_remote_commands = true; set citus.log_remote_commands = true;
set citus.grep_remote_commands = "%ALTER DATABASE%"; set citus.grep_remote_commands = "%ALTER DATABASE%";
alter database altered_database set tablespace alter_db_tablespace;
alter database altered_database rename to altered_database_renamed; alter database altered_database rename to altered_database_renamed;
alter database altered_database_renamed rename to altered_database; alter database altered_database_renamed rename to altered_database;
@ -62,3 +76,9 @@ drop database test_alter_db_from_nonmain_db;
reset citus.enable_create_database_propagation; reset citus.enable_create_database_propagation;
drop role test_owner_non_main_db; drop role test_owner_non_main_db;
SELECT result FROM run_command_on_all_nodes(
$$
drop tablespace alter_db_tablespace
$$
);