Skip to content

Commit

Permalink
Disable warnings for remote_txn
Browse files Browse the repository at this point in the history
For the tests that are using the `remote_node_set_kill_event` function
to perform a hard termination and precise stages of the 2PC the
connection will close with different warning messages depending on the
timing of connection close and SSL close.

To avoid a flaky test, this commit set `client_min_messages` to `ERROR`
for the duration of the transaction. Since checks are done after the
transaction that the transaction is properly rolled back in the event
of a crash, the warning messages does not offer any additional
benefits.
  • Loading branch information
mkindahl authored and erimatnor committed May 27, 2020
1 parent ad8b70a commit 5fd363d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 18 deletions.
31 changes: 16 additions & 15 deletions tsl/test/expected/remote_txn.out
Expand Up @@ -623,8 +623,14 @@ SELECT count(*) FROM pg_prepared_xacts;
0
(1 row)

--below will fail the abort and thus ROLLBACK TRANSACTION will never be called leaving
--a prepared_xact that should be rolled back by heal server
-- Below will fail the abort and thus ROLLBACK TRANSACTION will never
-- be called leaving a prepared_xact that should be rolled back by
-- heal server.
--
-- We set min message level to "error" since different warnings can be
-- generated due to timing issues but check that the transaction was
-- rolled back after the commit.
SET client_min_messages TO error;
BEGIN;
SELECT remote_node_killer_set_event('pre-abort', 'loopback');
remote_node_killer_set_event
Expand All @@ -633,25 +639,20 @@ BEGIN;
(1 row)

SELECT test.remote_exec('{loopback}', $$ INSERT INTO "S 1"."T 1" VALUES (10011,1,'bleh', '2001-01-01', '2001-01-01', 'bleh') $$);
NOTICE: [loopback]: INSERT INTO "S 1"."T 1" VALUES (10011,1,'bleh', '2001-01-01', '2001-01-01', 'bleh')
remote_exec
-------------

(1 row)

SELECT test.remote_exec('{loopback2}', $$ INSERT INTO "S 1"."T 1" VALUES (10001,1,'bleh', '2001-01-01', '2001-01-01', 'bleh') $$);
NOTICE: [loopback2]: INSERT INTO "S 1"."T 1" VALUES (10001,1,'bleh', '2001-01-01', '2001-01-01', 'bleh')
remote_exec
-------------

(1 row)

COMMIT;
WARNING: kill event: pre-abort
WARNING: [loopback]: terminating connection due to administrator command
WARNING: [loopback]: SSL connection has been closed unexpectedly
WARNING: failure aborting remote transaction during local abort
ERROR: [loopback2]: duplicate key value violates unique constraint "t1_pkey"
RESET client_min_messages;
SELECT count(*) FROM "S 1"."T 1" WHERE "C 1" = 10011;
count
-------
Expand Down Expand Up @@ -734,7 +735,12 @@ SELECT count(*) FROM pg_prepared_xacts;
0
(1 row)

--test comm error in subtrans abort
-- Test comm error in subtrans abort
--
-- We set min message level to "error" since different warnings can be
-- generated due to timing issues but check that the transaction was
-- rolled back after the commit.
SET client_min_messages TO error;
BEGIN;
SELECT remote_node_killer_set_event('subxact-abort', 'loopback');
remote_node_killer_set_event
Expand All @@ -743,36 +749,31 @@ BEGIN;
(1 row)

SELECT test.remote_exec('{loopback}', $$ INSERT INTO "S 1"."T 1" VALUES (10017,1,'bleh', '2001-01-01', '2001-01-01', 'bleh') $$);
NOTICE: [loopback]: INSERT INTO "S 1"."T 1" VALUES (10017,1,'bleh', '2001-01-01', '2001-01-01', 'bleh')
remote_exec
-------------

(1 row)

SELECT test.remote_exec('{loopback2}', $$ INSERT INTO "S 1"."T 1" VALUES (10018,1,'bleh', '2001-01-01', '2001-01-01', 'bleh') $$);
NOTICE: [loopback2]: INSERT INTO "S 1"."T 1" VALUES (10018,1,'bleh', '2001-01-01', '2001-01-01', 'bleh')
remote_exec
-------------

(1 row)

SAVEPOINT save_1;
SELECT test.remote_exec('{loopback}', $$ INSERT INTO "S 1"."T 1" VALUES (10001,1,'bleh', '2001-01-01', '2001-01-01', 'bleh') $$);
NOTICE: [loopback]: INSERT INTO "S 1"."T 1" VALUES (10001,1,'bleh', '2001-01-01', '2001-01-01', 'bleh')
remote_exec
-------------

(1 row)

ROLLBACK TO SAVEPOINT save_1;
WARNING: kill event: subxact-abort
WARNING: [loopback]: terminating connection due to administrator command
WARNING: [loopback]: SSL connection has been closed unexpectedly
SELECT test.remote_exec('{loopback}', $$ INSERT INTO "S 1"."T 1" VALUES (10019,1,'bleh', '2001-01-01', '2001-01-01', 'bleh') $$);
ERROR: connection to data node "loopback" was lost
SELECT test.remote_exec('{loopback2}', $$ INSERT INTO "S 1"."T 1" VALUES (10020,1,'bleh', '2001-01-01', '2001-01-01', 'bleh') $$);
ERROR: current transaction is aborted, commands ignored until end of transaction block
COMMIT;
RESET client_min_messages;
SELECT count(*) FROM "S 1"."T 1" WHERE "C 1" > 10016;
count
-------
Expand Down
20 changes: 17 additions & 3 deletions tsl/test/sql/remote_txn.sql
Expand Up @@ -264,13 +264,21 @@ COMMIT;
SELECT count(*) FROM "S 1"."T 1" WHERE "C 1" = 10010;
SELECT count(*) FROM pg_prepared_xacts;

--below will fail the abort and thus ROLLBACK TRANSACTION will never be called leaving
--a prepared_xact that should be rolled back by heal server
-- Below will fail the abort and thus ROLLBACK TRANSACTION will never
-- be called leaving a prepared_xact that should be rolled back by
-- heal server.
--
-- We set min message level to "error" since different warnings can be
-- generated due to timing issues but check that the transaction was
-- rolled back after the commit.
SET client_min_messages TO error;
BEGIN;
SELECT remote_node_killer_set_event('pre-abort', 'loopback');
SELECT test.remote_exec('{loopback}', $$ INSERT INTO "S 1"."T 1" VALUES (10011,1,'bleh', '2001-01-01', '2001-01-01', 'bleh') $$);
SELECT test.remote_exec('{loopback2}', $$ INSERT INTO "S 1"."T 1" VALUES (10001,1,'bleh', '2001-01-01', '2001-01-01', 'bleh') $$);
COMMIT;
RESET client_min_messages;

SELECT count(*) FROM "S 1"."T 1" WHERE "C 1" = 10011;
SELECT count(*) FROM pg_prepared_xacts;
SELECT _timescaledb_internal.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback'));
Expand All @@ -291,7 +299,12 @@ COMMIT;
SELECT count(*) FROM "S 1"."T 1" WHERE "C 1" > 10011;
SELECT count(*) FROM pg_prepared_xacts;

--test comm error in subtrans abort
-- Test comm error in subtrans abort
--
-- We set min message level to "error" since different warnings can be
-- generated due to timing issues but check that the transaction was
-- rolled back after the commit.
SET client_min_messages TO error;
BEGIN;
SELECT remote_node_killer_set_event('subxact-abort', 'loopback');
SELECT test.remote_exec('{loopback}', $$ INSERT INTO "S 1"."T 1" VALUES (10017,1,'bleh', '2001-01-01', '2001-01-01', 'bleh') $$);
Expand All @@ -302,6 +315,7 @@ BEGIN;
SELECT test.remote_exec('{loopback}', $$ INSERT INTO "S 1"."T 1" VALUES (10019,1,'bleh', '2001-01-01', '2001-01-01', 'bleh') $$);
SELECT test.remote_exec('{loopback2}', $$ INSERT INTO "S 1"."T 1" VALUES (10020,1,'bleh', '2001-01-01', '2001-01-01', 'bleh') $$);
COMMIT;
RESET client_min_messages;

SELECT count(*) FROM "S 1"."T 1" WHERE "C 1" > 10016;
SELECT count(*) FROM pg_prepared_xacts;
Expand Down

0 comments on commit 5fd363d

Please sign in to comment.