mirror of https://github.com/citusdata/citus.git
Adds alt. output for failure_savepoints bcs of PG15 libpq error changes
Duplicated error/warning texts is now avoided in PG15. The whole test file has duplications hence I added an alternative. In some cases ERROR/WARNING order is swapped so I reduced the log level. Relevant PG commit: 618c16707a6d6e8f5c83ede2092975e4670201adnaisila/failure_pg15
parent
8faf731168
commit
8d087f3e63
|
@ -1,6 +1,11 @@
|
||||||
--
|
--
|
||||||
-- FAILURE_SAVEPOINTS
|
-- FAILURE_SAVEPOINTS
|
||||||
--
|
--
|
||||||
|
-- This test file has an alternative output because of the change in the
|
||||||
|
-- libpq messages in PG15. Mainly, duplicated error text is avoided.
|
||||||
|
-- The alternative output can be deleted when we drop support for PG14
|
||||||
|
-- One of relevant PG commits: 618c16707a6d6e8f5c83ede2092975e4670201ad
|
||||||
|
--
|
||||||
SELECT citus.mitmproxy('conn.allow()');
|
SELECT citus.mitmproxy('conn.allow()');
|
||||||
mitmproxy
|
mitmproxy
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -33,16 +38,10 @@ SELECT citus.mitmproxy('conn.onQuery(query="^SAVEPOINT").kill()');
|
||||||
|
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
SET client_min_messages TO ERROR;
|
||||||
BEGIN;
|
BEGIN;
|
||||||
INSERT INTO artists VALUES (5, 'Asher Lev');
|
INSERT INTO artists VALUES (5, 'Asher Lev');
|
||||||
SAVEPOINT s1;
|
SAVEPOINT s1;
|
||||||
WARNING: connection not open
|
|
||||||
CONTEXT: while executing command on localhost:xxxxx
|
|
||||||
WARNING: connection to the remote node localhost:xxxxx failed with the following error: connection not open
|
|
||||||
WARNING: connection not open
|
|
||||||
CONTEXT: while executing command on localhost:xxxxx
|
|
||||||
WARNING: connection not open
|
|
||||||
CONTEXT: while executing command on localhost:xxxxx
|
|
||||||
ERROR: connection not open
|
ERROR: connection not open
|
||||||
CONTEXT: while executing command on localhost:xxxxx
|
CONTEXT: while executing command on localhost:xxxxx
|
||||||
DELETE FROM artists WHERE id=4;
|
DELETE FROM artists WHERE id=4;
|
||||||
|
@ -50,6 +49,7 @@ ERROR: current transaction is aborted, commands ignored until end of transactio
|
||||||
RELEASE SAVEPOINT s1;
|
RELEASE SAVEPOINT s1;
|
||||||
ERROR: current transaction is aborted, commands ignored until end of transaction block
|
ERROR: current transaction is aborted, commands ignored until end of transaction block
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
RESET client_min_messages;
|
||||||
SELECT * FROM artists WHERE id IN (4, 5);
|
SELECT * FROM artists WHERE id IN (4, 5);
|
||||||
id | name
|
id | name
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -63,24 +63,16 @@ SELECT citus.mitmproxy('conn.onQuery(query="^RELEASE").kill()');
|
||||||
|
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
SET client_min_messages TO ERROR;
|
||||||
BEGIN;
|
BEGIN;
|
||||||
UPDATE artists SET name='a';
|
UPDATE artists SET name='a';
|
||||||
SAVEPOINT s1;
|
SAVEPOINT s1;
|
||||||
DELETE FROM artists WHERE id=4;
|
DELETE FROM artists WHERE id=4;
|
||||||
RELEASE SAVEPOINT s1;
|
RELEASE SAVEPOINT s1;
|
||||||
WARNING: AbortSubTransaction while in COMMIT state
|
|
||||||
WARNING: connection not open
|
|
||||||
CONTEXT: while executing command on localhost:xxxxx
|
|
||||||
WARNING: connection to the remote node localhost:xxxxx failed with the following error: connection not open
|
|
||||||
WARNING: connection not open
|
|
||||||
CONTEXT: while executing command on localhost:xxxxx
|
|
||||||
WARNING: connection not open
|
|
||||||
CONTEXT: while executing command on localhost:xxxxx
|
|
||||||
WARNING: savepoint "savepoint_2" does not exist
|
|
||||||
CONTEXT: while executing command on localhost:xxxxx
|
|
||||||
ERROR: connection not open
|
ERROR: connection not open
|
||||||
CONTEXT: while executing command on localhost:xxxxx
|
CONTEXT: while executing command on localhost:xxxxx
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
RESET client_min_messages;
|
||||||
SELECT * FROM artists WHERE id IN (4, 5);
|
SELECT * FROM artists WHERE id IN (4, 5);
|
||||||
id | name
|
id | name
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -101,8 +93,6 @@ DELETE FROM artists WHERE id=4;
|
||||||
ROLLBACK TO SAVEPOINT s1;
|
ROLLBACK TO SAVEPOINT s1;
|
||||||
WARNING: connection not open
|
WARNING: connection not open
|
||||||
CONTEXT: while executing command on localhost:xxxxx
|
CONTEXT: while executing command on localhost:xxxxx
|
||||||
WARNING: connection not open
|
|
||||||
CONTEXT: while executing command on localhost:xxxxx
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
ERROR: failure on connection marked as essential: localhost:xxxxx
|
ERROR: failure on connection marked as essential: localhost:xxxxx
|
||||||
SELECT * FROM artists WHERE id IN (4, 5);
|
SELECT * FROM artists WHERE id IN (4, 5);
|
||||||
|
@ -118,6 +108,7 @@ SELECT citus.mitmproxy('conn.onQuery(query="^RELEASE").after(1).kill()');
|
||||||
|
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
SET client_min_messages TO ERROR;
|
||||||
BEGIN;
|
BEGIN;
|
||||||
SAVEPOINT s1;
|
SAVEPOINT s1;
|
||||||
DELETE FROM artists WHERE id=4;
|
DELETE FROM artists WHERE id=4;
|
||||||
|
@ -125,17 +116,10 @@ RELEASE SAVEPOINT s1;
|
||||||
SAVEPOINT s2;
|
SAVEPOINT s2;
|
||||||
INSERT INTO artists VALUES (5, 'Jacob Kahn');
|
INSERT INTO artists VALUES (5, 'Jacob Kahn');
|
||||||
RELEASE SAVEPOINT s2;
|
RELEASE SAVEPOINT s2;
|
||||||
WARNING: AbortSubTransaction while in COMMIT state
|
|
||||||
WARNING: connection not open
|
|
||||||
CONTEXT: while executing command on localhost:xxxxx
|
|
||||||
WARNING: connection to the remote node localhost:xxxxx failed with the following error: connection not open
|
|
||||||
WARNING: connection not open
|
|
||||||
CONTEXT: while executing command on localhost:xxxxx
|
|
||||||
WARNING: connection not open
|
|
||||||
CONTEXT: while executing command on localhost:xxxxx
|
|
||||||
ERROR: connection not open
|
ERROR: connection not open
|
||||||
CONTEXT: while executing command on localhost:xxxxx
|
CONTEXT: while executing command on localhost:xxxxx
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
RESET client_min_messages;
|
||||||
SELECT * FROM artists WHERE id IN (4, 5);
|
SELECT * FROM artists WHERE id IN (4, 5);
|
||||||
id | name
|
id | name
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -158,8 +142,6 @@ DELETE FROM artists WHERE id=5;
|
||||||
ROLLBACK TO SAVEPOINT s2;
|
ROLLBACK TO SAVEPOINT s2;
|
||||||
WARNING: connection not open
|
WARNING: connection not open
|
||||||
CONTEXT: while executing command on localhost:xxxxx
|
CONTEXT: while executing command on localhost:xxxxx
|
||||||
WARNING: connection not open
|
|
||||||
CONTEXT: while executing command on localhost:xxxxx
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
ERROR: failure on connection marked as essential: localhost:xxxxx
|
ERROR: failure on connection marked as essential: localhost:xxxxx
|
||||||
SELECT * FROM artists WHERE id IN (4, 5);
|
SELECT * FROM artists WHERE id IN (4, 5);
|
||||||
|
@ -206,11 +188,8 @@ INSERT INTO artists VALUES (7, 'Emily Carr');
|
||||||
INSERT INTO artists VALUES (7, 'Emily Carr');
|
INSERT INTO artists VALUES (7, 'Emily Carr');
|
||||||
ROLLBACK TO SAVEPOINT s1;
|
ROLLBACK TO SAVEPOINT s1;
|
||||||
WARNING: connection not open
|
WARNING: connection not open
|
||||||
WARNING: connection not open
|
|
||||||
WARNING: connection not open
|
|
||||||
WARNING: connection to the remote node localhost:xxxxx failed with the following error: connection not open
|
WARNING: connection to the remote node localhost:xxxxx failed with the following error: connection not open
|
||||||
WARNING: connection not open
|
WARNING: connection not open
|
||||||
WARNING: connection not open
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
ERROR: failure on connection marked as essential: localhost:xxxxx
|
ERROR: failure on connection marked as essential: localhost:xxxxx
|
||||||
SELECT * FROM artists WHERE id=6;
|
SELECT * FROM artists WHERE id=6;
|
||||||
|
@ -239,13 +218,10 @@ SELECT citus.mitmproxy('conn.onQuery(query="^SAVEPOINT").kill()');
|
||||||
|
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
SET client_min_messages TO ERROR;
|
||||||
BEGIN;
|
BEGIN;
|
||||||
INSERT INTO researchers VALUES (7, 4, 'Jan Plaza');
|
INSERT INTO researchers VALUES (7, 4, 'Jan Plaza');
|
||||||
SAVEPOINT s1;
|
SAVEPOINT s1;
|
||||||
WARNING: connection not open
|
|
||||||
WARNING: connection to the remote node localhost:xxxxx failed with the following error: connection not open
|
|
||||||
WARNING: connection not open
|
|
||||||
WARNING: connection not open
|
|
||||||
ERROR: connection not open
|
ERROR: connection not open
|
||||||
INSERT INTO researchers VALUES (8, 4, 'Alonzo Church');
|
INSERT INTO researchers VALUES (8, 4, 'Alonzo Church');
|
||||||
ERROR: current transaction is aborted, commands ignored until end of transaction block
|
ERROR: current transaction is aborted, commands ignored until end of transaction block
|
||||||
|
@ -254,6 +230,7 @@ ERROR: savepoint "s1" does not exist
|
||||||
RELEASE SAVEPOINT s1;
|
RELEASE SAVEPOINT s1;
|
||||||
ERROR: current transaction is aborted, commands ignored until end of transaction block
|
ERROR: current transaction is aborted, commands ignored until end of transaction block
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
RESET client_min_messages;
|
||||||
-- should see correct results from healthy placement and one bad placement
|
-- should see correct results from healthy placement and one bad placement
|
||||||
SELECT * FROM researchers WHERE lab_id = 4;
|
SELECT * FROM researchers WHERE lab_id = 4;
|
||||||
id | lab_id | name
|
id | lab_id | name
|
||||||
|
@ -282,7 +259,6 @@ SAVEPOINT s1;
|
||||||
INSERT INTO researchers VALUES (8, 4, 'Alonzo Church');
|
INSERT INTO researchers VALUES (8, 4, 'Alonzo Church');
|
||||||
ROLLBACK TO s1;
|
ROLLBACK TO s1;
|
||||||
WARNING: connection not open
|
WARNING: connection not open
|
||||||
WARNING: connection not open
|
|
||||||
RELEASE SAVEPOINT s1;
|
RELEASE SAVEPOINT s1;
|
||||||
COMMIT;
|
COMMIT;
|
||||||
ERROR: failure on connection marked as essential: localhost:xxxxx
|
ERROR: failure on connection marked as essential: localhost:xxxxx
|
||||||
|
@ -308,20 +284,16 @@ SELECT citus.mitmproxy('conn.onQuery(query="^RELEASE").kill()');
|
||||||
|
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
SET client_min_messages TO ERROR;
|
||||||
BEGIN;
|
BEGIN;
|
||||||
INSERT INTO researchers VALUES (7, 4, 'Jan Plaza');
|
INSERT INTO researchers VALUES (7, 4, 'Jan Plaza');
|
||||||
SAVEPOINT s1;
|
SAVEPOINT s1;
|
||||||
INSERT INTO researchers VALUES (8, 4, 'Alonzo Church');
|
INSERT INTO researchers VALUES (8, 4, 'Alonzo Church');
|
||||||
ROLLBACK TO s1;
|
ROLLBACK TO s1;
|
||||||
RELEASE SAVEPOINT s1;
|
RELEASE SAVEPOINT s1;
|
||||||
WARNING: AbortSubTransaction while in COMMIT state
|
|
||||||
WARNING: connection not open
|
|
||||||
WARNING: connection to the remote node localhost:xxxxx failed with the following error: connection not open
|
|
||||||
WARNING: connection not open
|
|
||||||
WARNING: connection not open
|
|
||||||
WARNING: savepoint "savepoint_3" does not exist
|
|
||||||
ERROR: connection not open
|
ERROR: connection not open
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
RESET client_min_messages;
|
||||||
-- should see correct results from healthy placement and one bad placement
|
-- should see correct results from healthy placement and one bad placement
|
||||||
SELECT * FROM researchers WHERE lab_id = 4;
|
SELECT * FROM researchers WHERE lab_id = 4;
|
||||||
id | lab_id | name
|
id | lab_id | name
|
||||||
|
@ -351,6 +323,7 @@ SELECT citus.mitmproxy('conn.onQuery(query="^ROLLBACK").kill()');
|
||||||
|
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
SET client_min_messages TO ERROR;
|
||||||
BEGIN;
|
BEGIN;
|
||||||
SAVEPOINT start;
|
SAVEPOINT start;
|
||||||
INSERT INTO ref VALUES (1001,2);
|
INSERT INTO ref VALUES (1001,2);
|
||||||
|
@ -361,15 +334,10 @@ SELECT * FROM ref;
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
ROLLBACK TO SAVEPOINT start;
|
ROLLBACK TO SAVEPOINT start;
|
||||||
WARNING: connection not open
|
|
||||||
WARNING: connection not open
|
|
||||||
SELECT * FROM ref;
|
SELECT * FROM ref;
|
||||||
WARNING: connection not open
|
|
||||||
WARNING: connection to the remote node localhost:xxxxx failed with the following error: connection not open
|
|
||||||
WARNING: connection not open
|
|
||||||
WARNING: connection not open
|
|
||||||
ERROR: connection to the remote node localhost:xxxxx failed with the following error: connection not open
|
ERROR: connection to the remote node localhost:xxxxx failed with the following error: connection not open
|
||||||
END;
|
END;
|
||||||
|
RESET client_min_messages;
|
||||||
-- clean up
|
-- clean up
|
||||||
SELECT citus.mitmproxy('conn.allow()');
|
SELECT citus.mitmproxy('conn.allow()');
|
||||||
mitmproxy
|
mitmproxy
|
||||||
|
|
|
@ -0,0 +1,358 @@
|
||||||
|
--
|
||||||
|
-- FAILURE_SAVEPOINTS
|
||||||
|
--
|
||||||
|
-- This test file has an alternative output because of the change in the
|
||||||
|
-- libpq messages in PG15. Mainly, duplicated error text is avoided.
|
||||||
|
-- The alternative output can be deleted when we drop support for PG14
|
||||||
|
-- One of relevant PG commits: 618c16707a6d6e8f5c83ede2092975e4670201ad
|
||||||
|
--
|
||||||
|
SELECT citus.mitmproxy('conn.allow()');
|
||||||
|
mitmproxy
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SET citus.shard_count = 2;
|
||||||
|
SET citus.shard_replication_factor = 1; -- one shard per worker
|
||||||
|
SET citus.next_shard_id TO 100950;
|
||||||
|
ALTER SEQUENCE pg_catalog.pg_dist_placement_placementid_seq RESTART 150;
|
||||||
|
CREATE TABLE artists (
|
||||||
|
id bigint NOT NULL,
|
||||||
|
name text NOT NULL
|
||||||
|
);
|
||||||
|
SELECT create_distributed_table('artists', 'id');
|
||||||
|
create_distributed_table
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- add some data
|
||||||
|
INSERT INTO artists VALUES (1, 'Pablo Picasso');
|
||||||
|
INSERT INTO artists VALUES (2, 'Vincent van Gogh');
|
||||||
|
INSERT INTO artists VALUES (3, 'Claude Monet');
|
||||||
|
INSERT INTO artists VALUES (4, 'William Kurelek');
|
||||||
|
-- simply fail at SAVEPOINT
|
||||||
|
SELECT citus.mitmproxy('conn.onQuery(query="^SAVEPOINT").kill()');
|
||||||
|
mitmproxy
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SET client_min_messages TO ERROR;
|
||||||
|
BEGIN;
|
||||||
|
INSERT INTO artists VALUES (5, 'Asher Lev');
|
||||||
|
SAVEPOINT s1;
|
||||||
|
ERROR: connection not open
|
||||||
|
CONTEXT: while executing command on localhost:xxxxx
|
||||||
|
DELETE FROM artists WHERE id=4;
|
||||||
|
ERROR: current transaction is aborted, commands ignored until end of transaction block
|
||||||
|
RELEASE SAVEPOINT s1;
|
||||||
|
ERROR: current transaction is aborted, commands ignored until end of transaction block
|
||||||
|
COMMIT;
|
||||||
|
RESET client_min_messages;
|
||||||
|
SELECT * FROM artists WHERE id IN (4, 5);
|
||||||
|
id | name
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
4 | William Kurelek
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- fail at RELEASE
|
||||||
|
SELECT citus.mitmproxy('conn.onQuery(query="^RELEASE").kill()');
|
||||||
|
mitmproxy
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SET client_min_messages TO ERROR;
|
||||||
|
BEGIN;
|
||||||
|
UPDATE artists SET name='a';
|
||||||
|
SAVEPOINT s1;
|
||||||
|
DELETE FROM artists WHERE id=4;
|
||||||
|
RELEASE SAVEPOINT s1;
|
||||||
|
ERROR: connection not open
|
||||||
|
CONTEXT: while executing command on localhost:xxxxx
|
||||||
|
ROLLBACK;
|
||||||
|
RESET client_min_messages;
|
||||||
|
SELECT * FROM artists WHERE id IN (4, 5);
|
||||||
|
id | name
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
4 | William Kurelek
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- fail at ROLLBACK
|
||||||
|
SELECT citus.mitmproxy('conn.onQuery(query="^ROLLBACK").kill()');
|
||||||
|
mitmproxy
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
BEGIN;
|
||||||
|
INSERT INTO artists VALUES (5, 'Asher Lev');
|
||||||
|
SAVEPOINT s1;
|
||||||
|
DELETE FROM artists WHERE id=4;
|
||||||
|
ROLLBACK TO SAVEPOINT s1;
|
||||||
|
WARNING: connection not open
|
||||||
|
CONTEXT: while executing command on localhost:xxxxx
|
||||||
|
WARNING: connection not open
|
||||||
|
CONTEXT: while executing command on localhost:xxxxx
|
||||||
|
COMMIT;
|
||||||
|
ERROR: failure on connection marked as essential: localhost:xxxxx
|
||||||
|
SELECT * FROM artists WHERE id IN (4, 5);
|
||||||
|
id | name
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
4 | William Kurelek
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- fail at second RELEASE
|
||||||
|
SELECT citus.mitmproxy('conn.onQuery(query="^RELEASE").after(1).kill()');
|
||||||
|
mitmproxy
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SET client_min_messages TO ERROR;
|
||||||
|
BEGIN;
|
||||||
|
SAVEPOINT s1;
|
||||||
|
DELETE FROM artists WHERE id=4;
|
||||||
|
RELEASE SAVEPOINT s1;
|
||||||
|
SAVEPOINT s2;
|
||||||
|
INSERT INTO artists VALUES (5, 'Jacob Kahn');
|
||||||
|
RELEASE SAVEPOINT s2;
|
||||||
|
ERROR: connection not open
|
||||||
|
CONTEXT: while executing command on localhost:xxxxx
|
||||||
|
COMMIT;
|
||||||
|
RESET client_min_messages;
|
||||||
|
SELECT * FROM artists WHERE id IN (4, 5);
|
||||||
|
id | name
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
4 | William Kurelek
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- fail at second ROLLBACK
|
||||||
|
SELECT citus.mitmproxy('conn.onQuery(query="^ROLLBACK").after(1).kill()');
|
||||||
|
mitmproxy
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
BEGIN;
|
||||||
|
SAVEPOINT s1;
|
||||||
|
UPDATE artists SET name='A' WHERE id=4;
|
||||||
|
ROLLBACK TO SAVEPOINT s1;
|
||||||
|
SAVEPOINT s2;
|
||||||
|
DELETE FROM artists WHERE id=5;
|
||||||
|
ROLLBACK TO SAVEPOINT s2;
|
||||||
|
WARNING: connection not open
|
||||||
|
CONTEXT: while executing command on localhost:xxxxx
|
||||||
|
WARNING: connection not open
|
||||||
|
CONTEXT: while executing command on localhost:xxxxx
|
||||||
|
COMMIT;
|
||||||
|
ERROR: failure on connection marked as essential: localhost:xxxxx
|
||||||
|
SELECT * FROM artists WHERE id IN (4, 5);
|
||||||
|
id | name
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
4 | William Kurelek
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT citus.mitmproxy('conn.onQuery(query="^RELEASE").after(1).kill()');
|
||||||
|
mitmproxy
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- Release after rollback
|
||||||
|
BEGIN;
|
||||||
|
SAVEPOINT s1;
|
||||||
|
ROLLBACK TO s1;
|
||||||
|
RELEASE SAVEPOINT s1;
|
||||||
|
SAVEPOINT s2;
|
||||||
|
INSERT INTO artists VALUES (6, 'John J. Audubon');
|
||||||
|
INSERT INTO artists VALUES (7, 'Emily Carr');
|
||||||
|
ROLLBACK TO s2;
|
||||||
|
RELEASE SAVEPOINT s2;
|
||||||
|
COMMIT;
|
||||||
|
SELECT * FROM artists WHERE id=7;
|
||||||
|
id | name
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
(0 rows)
|
||||||
|
|
||||||
|
SELECT citus.mitmproxy('conn.onQuery(query="^ROLLBACK").kill()');
|
||||||
|
mitmproxy
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- Recover from errors
|
||||||
|
\set VERBOSITY terse
|
||||||
|
BEGIN;
|
||||||
|
SAVEPOINT s1;
|
||||||
|
SAVEPOINT s2;
|
||||||
|
INSERT INTO artists VALUES (6, 'John J. Audubon');
|
||||||
|
INSERT INTO artists VALUES (7, 'Emily Carr');
|
||||||
|
INSERT INTO artists VALUES (7, 'Emily Carr');
|
||||||
|
ROLLBACK TO SAVEPOINT s1;
|
||||||
|
WARNING: connection not open
|
||||||
|
WARNING: connection not open
|
||||||
|
WARNING: connection not open
|
||||||
|
WARNING: connection to the remote node localhost:xxxxx failed with the following error: connection not open
|
||||||
|
WARNING: connection not open
|
||||||
|
WARNING: connection not open
|
||||||
|
COMMIT;
|
||||||
|
ERROR: failure on connection marked as essential: localhost:xxxxx
|
||||||
|
SELECT * FROM artists WHERE id=6;
|
||||||
|
id | name
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
(0 rows)
|
||||||
|
|
||||||
|
-- replication factor > 1
|
||||||
|
CREATE TABLE researchers (
|
||||||
|
id bigint NOT NULL,
|
||||||
|
lab_id int NOT NULL,
|
||||||
|
name text NOT NULL
|
||||||
|
);
|
||||||
|
SET citus.shard_count = 1;
|
||||||
|
SET citus.shard_replication_factor = 2; -- single shard, on both workers
|
||||||
|
SELECT create_distributed_table('researchers', 'lab_id', 'hash');
|
||||||
|
create_distributed_table
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- simply fail at SAVEPOINT
|
||||||
|
SELECT citus.mitmproxy('conn.onQuery(query="^SAVEPOINT").kill()');
|
||||||
|
mitmproxy
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SET client_min_messages TO ERROR;
|
||||||
|
BEGIN;
|
||||||
|
INSERT INTO researchers VALUES (7, 4, 'Jan Plaza');
|
||||||
|
SAVEPOINT s1;
|
||||||
|
ERROR: connection not open
|
||||||
|
INSERT INTO researchers VALUES (8, 4, 'Alonzo Church');
|
||||||
|
ERROR: current transaction is aborted, commands ignored until end of transaction block
|
||||||
|
ROLLBACK TO s1;
|
||||||
|
ERROR: savepoint "s1" does not exist
|
||||||
|
RELEASE SAVEPOINT s1;
|
||||||
|
ERROR: current transaction is aborted, commands ignored until end of transaction block
|
||||||
|
COMMIT;
|
||||||
|
RESET client_min_messages;
|
||||||
|
-- should see correct results from healthy placement and one bad placement
|
||||||
|
SELECT * FROM researchers WHERE lab_id = 4;
|
||||||
|
id | lab_id | name
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
(0 rows)
|
||||||
|
|
||||||
|
UPDATE pg_dist_shard_placement SET shardstate = 1
|
||||||
|
WHERE shardstate = 3 AND shardid IN (
|
||||||
|
SELECT shardid FROM pg_dist_shard WHERE logicalrelid = 'researchers'::regclass
|
||||||
|
) RETURNING placementid;
|
||||||
|
placementid
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
(0 rows)
|
||||||
|
|
||||||
|
TRUNCATE researchers;
|
||||||
|
-- fail at rollback
|
||||||
|
SELECT citus.mitmproxy('conn.onQuery(query="^ROLLBACK").kill()');
|
||||||
|
mitmproxy
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
BEGIN;
|
||||||
|
INSERT INTO researchers VALUES (7, 4, 'Jan Plaza');
|
||||||
|
SAVEPOINT s1;
|
||||||
|
INSERT INTO researchers VALUES (8, 4, 'Alonzo Church');
|
||||||
|
ROLLBACK TO s1;
|
||||||
|
WARNING: connection not open
|
||||||
|
WARNING: connection not open
|
||||||
|
RELEASE SAVEPOINT s1;
|
||||||
|
COMMIT;
|
||||||
|
ERROR: failure on connection marked as essential: localhost:xxxxx
|
||||||
|
-- should see correct results from healthy placement and one bad placement
|
||||||
|
SELECT * FROM researchers WHERE lab_id = 4;
|
||||||
|
id | lab_id | name
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
(0 rows)
|
||||||
|
|
||||||
|
UPDATE pg_dist_shard_placement SET shardstate = 1
|
||||||
|
WHERE shardstate = 3 AND shardid IN (
|
||||||
|
SELECT shardid FROM pg_dist_shard WHERE logicalrelid = 'researchers'::regclass
|
||||||
|
) RETURNING placementid;
|
||||||
|
placementid
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
(0 rows)
|
||||||
|
|
||||||
|
TRUNCATE researchers;
|
||||||
|
-- fail at release
|
||||||
|
SELECT citus.mitmproxy('conn.onQuery(query="^RELEASE").kill()');
|
||||||
|
mitmproxy
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SET client_min_messages TO ERROR;
|
||||||
|
BEGIN;
|
||||||
|
INSERT INTO researchers VALUES (7, 4, 'Jan Plaza');
|
||||||
|
SAVEPOINT s1;
|
||||||
|
INSERT INTO researchers VALUES (8, 4, 'Alonzo Church');
|
||||||
|
ROLLBACK TO s1;
|
||||||
|
RELEASE SAVEPOINT s1;
|
||||||
|
ERROR: connection not open
|
||||||
|
COMMIT;
|
||||||
|
RESET client_min_messages;
|
||||||
|
-- should see correct results from healthy placement and one bad placement
|
||||||
|
SELECT * FROM researchers WHERE lab_id = 4;
|
||||||
|
id | lab_id | name
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
(0 rows)
|
||||||
|
|
||||||
|
UPDATE pg_dist_shard_placement SET shardstate = 1
|
||||||
|
WHERE shardstate = 3 AND shardid IN (
|
||||||
|
SELECT shardid FROM pg_dist_shard WHERE logicalrelid = 'researchers'::regclass
|
||||||
|
) RETURNING placementid;
|
||||||
|
placementid
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
(0 rows)
|
||||||
|
|
||||||
|
TRUNCATE researchers;
|
||||||
|
-- test that we don't mark reference placements unhealthy
|
||||||
|
CREATE TABLE ref(a int, b int);
|
||||||
|
SELECT create_reference_table('ref');
|
||||||
|
create_reference_table
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT citus.mitmproxy('conn.onQuery(query="^ROLLBACK").kill()');
|
||||||
|
mitmproxy
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SET client_min_messages TO ERROR;
|
||||||
|
BEGIN;
|
||||||
|
SAVEPOINT start;
|
||||||
|
INSERT INTO ref VALUES (1001,2);
|
||||||
|
SELECT * FROM ref;
|
||||||
|
a | b
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
1001 | 2
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
ROLLBACK TO SAVEPOINT start;
|
||||||
|
SELECT * FROM ref;
|
||||||
|
ERROR: connection to the remote node localhost:xxxxx failed with the following error: connection not open
|
||||||
|
END;
|
||||||
|
RESET client_min_messages;
|
||||||
|
-- clean up
|
||||||
|
SELECT citus.mitmproxy('conn.allow()');
|
||||||
|
mitmproxy
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
DROP TABLE artists;
|
||||||
|
DROP TABLE researchers;
|
||||||
|
DROP TABLE ref;
|
|
@ -1,6 +1,11 @@
|
||||||
--
|
--
|
||||||
-- FAILURE_SAVEPOINTS
|
-- FAILURE_SAVEPOINTS
|
||||||
--
|
--
|
||||||
|
-- This test file has an alternative output because of the change in the
|
||||||
|
-- libpq messages in PG15. Mainly, duplicated error text is avoided.
|
||||||
|
-- The alternative output can be deleted when we drop support for PG14
|
||||||
|
-- One of relevant PG commits: 618c16707a6d6e8f5c83ede2092975e4670201ad
|
||||||
|
--
|
||||||
|
|
||||||
SELECT citus.mitmproxy('conn.allow()');
|
SELECT citus.mitmproxy('conn.allow()');
|
||||||
|
|
||||||
|
@ -24,24 +29,28 @@ INSERT INTO artists VALUES (4, 'William Kurelek');
|
||||||
-- simply fail at SAVEPOINT
|
-- simply fail at SAVEPOINT
|
||||||
SELECT citus.mitmproxy('conn.onQuery(query="^SAVEPOINT").kill()');
|
SELECT citus.mitmproxy('conn.onQuery(query="^SAVEPOINT").kill()');
|
||||||
|
|
||||||
|
SET client_min_messages TO ERROR;
|
||||||
BEGIN;
|
BEGIN;
|
||||||
INSERT INTO artists VALUES (5, 'Asher Lev');
|
INSERT INTO artists VALUES (5, 'Asher Lev');
|
||||||
SAVEPOINT s1;
|
SAVEPOINT s1;
|
||||||
DELETE FROM artists WHERE id=4;
|
DELETE FROM artists WHERE id=4;
|
||||||
RELEASE SAVEPOINT s1;
|
RELEASE SAVEPOINT s1;
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
RESET client_min_messages;
|
||||||
|
|
||||||
SELECT * FROM artists WHERE id IN (4, 5);
|
SELECT * FROM artists WHERE id IN (4, 5);
|
||||||
|
|
||||||
-- fail at RELEASE
|
-- fail at RELEASE
|
||||||
SELECT citus.mitmproxy('conn.onQuery(query="^RELEASE").kill()');
|
SELECT citus.mitmproxy('conn.onQuery(query="^RELEASE").kill()');
|
||||||
|
|
||||||
|
SET client_min_messages TO ERROR;
|
||||||
BEGIN;
|
BEGIN;
|
||||||
UPDATE artists SET name='a';
|
UPDATE artists SET name='a';
|
||||||
SAVEPOINT s1;
|
SAVEPOINT s1;
|
||||||
DELETE FROM artists WHERE id=4;
|
DELETE FROM artists WHERE id=4;
|
||||||
RELEASE SAVEPOINT s1;
|
RELEASE SAVEPOINT s1;
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
RESET client_min_messages;
|
||||||
|
|
||||||
SELECT * FROM artists WHERE id IN (4, 5);
|
SELECT * FROM artists WHERE id IN (4, 5);
|
||||||
|
|
||||||
|
@ -59,6 +68,9 @@ SELECT * FROM artists WHERE id IN (4, 5);
|
||||||
|
|
||||||
-- fail at second RELEASE
|
-- fail at second RELEASE
|
||||||
SELECT citus.mitmproxy('conn.onQuery(query="^RELEASE").after(1).kill()');
|
SELECT citus.mitmproxy('conn.onQuery(query="^RELEASE").after(1).kill()');
|
||||||
|
|
||||||
|
SET client_min_messages TO ERROR;
|
||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
SAVEPOINT s1;
|
SAVEPOINT s1;
|
||||||
DELETE FROM artists WHERE id=4;
|
DELETE FROM artists WHERE id=4;
|
||||||
|
@ -68,6 +80,8 @@ INSERT INTO artists VALUES (5, 'Jacob Kahn');
|
||||||
RELEASE SAVEPOINT s2;
|
RELEASE SAVEPOINT s2;
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
||||||
|
RESET client_min_messages;
|
||||||
|
|
||||||
SELECT * FROM artists WHERE id IN (4, 5);
|
SELECT * FROM artists WHERE id IN (4, 5);
|
||||||
|
|
||||||
-- fail at second ROLLBACK
|
-- fail at second ROLLBACK
|
||||||
|
@ -129,6 +143,8 @@ SELECT create_distributed_table('researchers', 'lab_id', 'hash');
|
||||||
-- simply fail at SAVEPOINT
|
-- simply fail at SAVEPOINT
|
||||||
SELECT citus.mitmproxy('conn.onQuery(query="^SAVEPOINT").kill()');
|
SELECT citus.mitmproxy('conn.onQuery(query="^SAVEPOINT").kill()');
|
||||||
|
|
||||||
|
SET client_min_messages TO ERROR;
|
||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
INSERT INTO researchers VALUES (7, 4, 'Jan Plaza');
|
INSERT INTO researchers VALUES (7, 4, 'Jan Plaza');
|
||||||
SAVEPOINT s1;
|
SAVEPOINT s1;
|
||||||
|
@ -137,6 +153,8 @@ ROLLBACK TO s1;
|
||||||
RELEASE SAVEPOINT s1;
|
RELEASE SAVEPOINT s1;
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
||||||
|
RESET client_min_messages;
|
||||||
|
|
||||||
-- should see correct results from healthy placement and one bad placement
|
-- should see correct results from healthy placement and one bad placement
|
||||||
SELECT * FROM researchers WHERE lab_id = 4;
|
SELECT * FROM researchers WHERE lab_id = 4;
|
||||||
|
|
||||||
|
@ -169,6 +187,8 @@ TRUNCATE researchers;
|
||||||
-- fail at release
|
-- fail at release
|
||||||
SELECT citus.mitmproxy('conn.onQuery(query="^RELEASE").kill()');
|
SELECT citus.mitmproxy('conn.onQuery(query="^RELEASE").kill()');
|
||||||
|
|
||||||
|
SET client_min_messages TO ERROR;
|
||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
INSERT INTO researchers VALUES (7, 4, 'Jan Plaza');
|
INSERT INTO researchers VALUES (7, 4, 'Jan Plaza');
|
||||||
SAVEPOINT s1;
|
SAVEPOINT s1;
|
||||||
|
@ -177,6 +197,8 @@ ROLLBACK TO s1;
|
||||||
RELEASE SAVEPOINT s1;
|
RELEASE SAVEPOINT s1;
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
||||||
|
RESET client_min_messages;
|
||||||
|
|
||||||
-- should see correct results from healthy placement and one bad placement
|
-- should see correct results from healthy placement and one bad placement
|
||||||
SELECT * FROM researchers WHERE lab_id = 4;
|
SELECT * FROM researchers WHERE lab_id = 4;
|
||||||
|
|
||||||
|
@ -191,6 +213,9 @@ CREATE TABLE ref(a int, b int);
|
||||||
SELECT create_reference_table('ref');
|
SELECT create_reference_table('ref');
|
||||||
|
|
||||||
SELECT citus.mitmproxy('conn.onQuery(query="^ROLLBACK").kill()');
|
SELECT citus.mitmproxy('conn.onQuery(query="^ROLLBACK").kill()');
|
||||||
|
|
||||||
|
SET client_min_messages TO ERROR;
|
||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
SAVEPOINT start;
|
SAVEPOINT start;
|
||||||
INSERT INTO ref VALUES (1001,2);
|
INSERT INTO ref VALUES (1001,2);
|
||||||
|
@ -199,6 +224,8 @@ ROLLBACK TO SAVEPOINT start;
|
||||||
SELECT * FROM ref;
|
SELECT * FROM ref;
|
||||||
END;
|
END;
|
||||||
|
|
||||||
|
RESET client_min_messages;
|
||||||
|
|
||||||
-- clean up
|
-- clean up
|
||||||
SELECT citus.mitmproxy('conn.allow()');
|
SELECT citus.mitmproxy('conn.allow()');
|
||||||
DROP TABLE artists;
|
DROP TABLE artists;
|
||||||
|
|
Loading…
Reference in New Issue