From 3c343d45633c95e249dfcb419dabc659e2b78066 Mon Sep 17 00:00:00 2001 From: Onder Kalaci Date: Wed, 13 Jul 2022 14:27:11 +0200 Subject: [PATCH] Add regression tests for LOCK command citus.use_secondary_nodes=always mode --- .../regress/expected/multi_follower_dml.out | 27 +++++++++++++++++++ src/test/regress/sql/multi_follower_dml.sql | 14 ++++++++++ 2 files changed, 41 insertions(+) diff --git a/src/test/regress/expected/multi_follower_dml.out b/src/test/regress/expected/multi_follower_dml.out index d6a5acd65..e343f0a6d 100644 --- a/src/test/regress/expected/multi_follower_dml.out +++ b/src/test/regress/expected/multi_follower_dml.out @@ -354,6 +354,33 @@ ERROR: writing to worker nodes is not currently allowed DETAIL: citus.use_secondary_nodes is set to 'always' SELECT * FROM citus_local_table ORDER BY a; ERROR: there is a shard placement in node group 0 but there are no nodes in that group +\c "port=57636 dbname=regression options='-c\ citus.use_secondary_nodes=always\ -c\ citus.cluster_name=second-cluster'" +-- when an existing read-replica is forked to become +-- another primary node, we sometimes have to use citus.use_secondary_nodes=always +-- even if the node is not in recovery mode. In those cases, allow LOCK +-- command on local / metadata tables, and also certain UDFs +SHOW citus.use_secondary_nodes; + citus.use_secondary_nodes +--------------------------------------------------------------------- + always +(1 row) + +SELECT pg_is_in_recovery(); + pg_is_in_recovery +--------------------------------------------------------------------- + f +(1 row) + +SELECT citus_is_coordinator(); + citus_is_coordinator +--------------------------------------------------------------------- + t +(1 row) + +BEGIN; + LOCK TABLE pg_dist_node IN SHARE ROW EXCLUSIVE MODE; + LOCK TABLE local IN SHARE ROW EXCLUSIVE MODE; +COMMIT; \c -reuse-previous=off regression - - :master_port DROP TABLE the_table; DROP TABLE reference_table; diff --git a/src/test/regress/sql/multi_follower_dml.sql b/src/test/regress/sql/multi_follower_dml.sql index dc03f258c..a3d548b12 100644 --- a/src/test/regress/sql/multi_follower_dml.sql +++ b/src/test/regress/sql/multi_follower_dml.sql @@ -163,6 +163,20 @@ SELECT * FROM reference_table ORDER BY a; INSERT INTO citus_local_table (a, b, z) VALUES (1, 2, 3); SELECT * FROM citus_local_table ORDER BY a; +\c "port=57636 dbname=regression options='-c\ citus.use_secondary_nodes=always\ -c\ citus.cluster_name=second-cluster'" + +-- when an existing read-replica is forked to become +-- another primary node, we sometimes have to use citus.use_secondary_nodes=always +-- even if the node is not in recovery mode. In those cases, allow LOCK +-- command on local / metadata tables, and also certain UDFs +SHOW citus.use_secondary_nodes; +SELECT pg_is_in_recovery(); +SELECT citus_is_coordinator(); +BEGIN; + LOCK TABLE pg_dist_node IN SHARE ROW EXCLUSIVE MODE; + LOCK TABLE local IN SHARE ROW EXCLUSIVE MODE; +COMMIT; + \c -reuse-previous=off regression - - :master_port DROP TABLE the_table; DROP TABLE reference_table;