\c - - - :master_port CREATE TABLE the_table (a int, b int, z bigserial); SELECT create_distributed_table('the_table', 'a'); create_distributed_table --------------------------------------------------------------------- (1 row) CREATE TABLE local (a int, b int); \c - - - :follower_master_port -- inserts normally do not work on a standby coordinator INSERT INTO the_table (a, b, z) VALUES (1, 2, 2); ERROR: writing to worker nodes is not currently allowed DETAIL: the database is read-only -- we can allow DML on a writable standby coordinator SET citus.writable_standby_coordinator TO on; INSERT INTO the_table (a, b, z) VALUES (1, 2, 2); SELECT * FROM the_table; a | b | z --------------------------------------------------------------------- 1 | 2 | 2 (1 row) UPDATE the_table SET z = 3 WHERE a = 1; SELECT * FROM the_table; a | b | z --------------------------------------------------------------------- 1 | 2 | 3 (1 row) DELETE FROM the_table WHERE a = 1; SELECT * FROM the_table; a | b | z --------------------------------------------------------------------- (0 rows) -- drawing from a sequence is not possible INSERT INTO the_table (a, b) VALUES (1, 2); ERROR: cannot assign TransactionIds during recovery -- 2PC is not possible INSERT INTO the_table (a, b, z) VALUES (2, 3, 4), (5, 6, 7); ERROR: cannot assign TransactionIds during recovery -- COPY is not possible in 2PC mode COPY the_table (a, b, z) FROM STDIN WITH CSV; ERROR: cannot assign TransactionIds during recovery -- 1PC is possible SET citus.multi_shard_commit_protocol TO '1pc'; INSERT INTO the_table (a, b, z) VALUES (2, 3, 4), (5, 6, 7); SELECT * FROM the_table ORDER BY a; a | b | z --------------------------------------------------------------------- 2 | 3 | 4 5 | 6 | 7 (2 rows) -- modifying CTEs are possible WITH del AS (DELETE FROM the_table RETURNING *) SELECT * FROM del ORDER BY a; a | b | z --------------------------------------------------------------------- 2 | 3 | 4 5 | 6 | 7 (2 rows) -- COPY is possible in 1PC mode COPY the_table (a, b, z) FROM STDIN WITH CSV; SELECT * FROM the_table ORDER BY a; a | b | z --------------------------------------------------------------------- 10 | 10 | 10 11 | 11 | 11 (2 rows) DELETE FROM the_table; -- DDL is not possible TRUNCATE the_table; ERROR: cannot execute TRUNCATE TABLE in a read-only transaction ALTER TABLE the_table ADD COLUMN c int; ERROR: cannot acquire lock mode AccessExclusiveLock on database objects while recovery is in progress HINT: Only RowExclusiveLock or less can be acquired on database objects during recovery. -- rollback is possible BEGIN; INSERT INTO the_table (a, b, z) VALUES (1, 2, 2); ROLLBACK; SELECT * FROM the_table ORDER BY a; a | b | z --------------------------------------------------------------------- (0 rows) -- we should still disallow writes to local tables INSERT INTO local VALUES (1, 1); ERROR: cannot execute INSERT in a read-only transaction INSERT INTO local SELECT a, b FROM the_table; ERROR: cannot execute INSERT in a read-only transaction -- we shouldn't be able to create local tables CREATE TEMP TABLE local_copy_of_the_table AS SELECT * FROM the_table; ERROR: cannot execute CREATE TABLE AS in a read-only transaction \c "port=9070 dbname=regression options='-c\ citus.use_secondary_nodes=always\ -c\ citus.cluster_name=second-cluster'" -- separate follower formations currently cannot do writes SET citus.writable_standby_coordinator TO on; INSERT INTO the_table (a, b, z) VALUES (1, 2, 3); ERROR: writing to worker nodes is not currently allowed DETAIL: citus.use_secondary_nodes is set to 'always' SELECT * FROM the_table ORDER BY a; a | b | z --------------------------------------------------------------------- (0 rows) \c - - - :master_port DROP TABLE the_table;