From 98e38e2e4e7285764c9e8ad74c943bc78741576b Mon Sep 17 00:00:00 2001 From: Halil Ozan Akgul Date: Mon, 13 Dec 2021 11:51:25 +0300 Subject: [PATCH] Fix metadata sync fails on failure_connection_establishment --- .../failure_connection_establishment.out | 19 ++++++++++++------- src/test/regress/failure_schedule | 2 +- .../sql/failure_connection_establishment.sql | 9 +++++---- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/test/regress/expected/failure_connection_establishment.out b/src/test/regress/expected/failure_connection_establishment.out index bb9b27681..199fb1d50 100644 --- a/src/test/regress/expected/failure_connection_establishment.out +++ b/src/test/regress/expected/failure_connection_establishment.out @@ -44,7 +44,8 @@ SELECT citus.mitmproxy('conn.delay(500)'); (1 row) ALTER TABLE products ADD CONSTRAINT p_key PRIMARY KEY(product_no); -ERROR: could not establish any connections to the node localhost:xxxxx after 400 ms +WARNING: could not establish connection after 400 ms +ERROR: connection to the remote node localhost:xxxxx failed SELECT citus.mitmproxy('conn.allow()'); mitmproxy --------------------------------------------------------------------- @@ -190,7 +191,7 @@ FROM pg_dist_shard_placement WHERE shardstate = 3 AND - shardid IN (SELECT shardid from pg_dist_shard where logicalrelid = 'products'::regclass); + shardid IN (SELECT shardid from pg_dist_shard where logicalrelid = 'single_replicatated'::regclass); invalid_placement_count --------------------------------------------------------------------- 0 @@ -202,7 +203,7 @@ SELECT citus.mitmproxy('conn.delay(500)'); (1 row) -INSERT INTO products VALUES (100, '100', 100); +INSERT INTO single_replicatated VALUES (100); ERROR: could not establish any connections to the node localhost:xxxxx after 400 ms COMMIT; SELECT @@ -211,14 +212,20 @@ FROM pg_dist_shard_placement WHERE shardstate = 3 AND - shardid IN (SELECT shardid from pg_dist_shard where logicalrelid = 'products'::regclass); + shardid IN (SELECT shardid from pg_dist_shard where logicalrelid = 'single_replicatated'::regclass); invalid_placement_count --------------------------------------------------------------------- 0 (1 row) -- show that INSERT failed -SELECT count(*) FROM products WHERE product_no = 100; +SELECT citus.mitmproxy('conn.allow()'); + mitmproxy +--------------------------------------------------------------------- + +(1 row) + +SELECT count(*) FROM single_replicatated WHERE key = 100; count --------------------------------------------------------------------- 0 @@ -227,8 +234,6 @@ SELECT count(*) FROM products WHERE product_no = 100; RESET client_min_messages; -- verify get_global_active_transactions works when a timeout happens on a connection SELECT get_global_active_transactions(); -WARNING: could not establish connection after 400 ms -WARNING: connection to the remote node localhost:xxxxx failed get_global_active_transactions --------------------------------------------------------------------- (0 rows) diff --git a/src/test/regress/failure_schedule b/src/test/regress/failure_schedule index 4353913b7..550544a7f 100644 --- a/src/test/regress/failure_schedule +++ b/src/test/regress/failure_schedule @@ -21,7 +21,6 @@ test: turn_mx_off test: failure_create_distributed_table_non_empty test: failure_create_table test: failure_single_select -test: failure_connection_establishment test: turn_mx_on test: failure_multi_shard_update_delete @@ -35,6 +34,7 @@ test: failure_single_mod test: failure_savepoints test: failure_multi_row_insert test: failure_mx_metadata_sync +test: failure_connection_establishment # this test syncs metadata to the workers test: failure_failover_to_local_execution diff --git a/src/test/regress/sql/failure_connection_establishment.sql b/src/test/regress/sql/failure_connection_establishment.sql index 70812e56a..e76296cc9 100644 --- a/src/test/regress/sql/failure_connection_establishment.sql +++ b/src/test/regress/sql/failure_connection_establishment.sql @@ -108,9 +108,9 @@ FROM pg_dist_shard_placement WHERE shardstate = 3 AND - shardid IN (SELECT shardid from pg_dist_shard where logicalrelid = 'products'::regclass); + shardid IN (SELECT shardid from pg_dist_shard where logicalrelid = 'single_replicatated'::regclass); SELECT citus.mitmproxy('conn.delay(500)'); -INSERT INTO products VALUES (100, '100', 100); +INSERT INTO single_replicatated VALUES (100); COMMIT; SELECT count(*) as invalid_placement_count @@ -118,10 +118,11 @@ FROM pg_dist_shard_placement WHERE shardstate = 3 AND - shardid IN (SELECT shardid from pg_dist_shard where logicalrelid = 'products'::regclass); + shardid IN (SELECT shardid from pg_dist_shard where logicalrelid = 'single_replicatated'::regclass); -- show that INSERT failed -SELECT count(*) FROM products WHERE product_no = 100; +SELECT citus.mitmproxy('conn.allow()'); +SELECT count(*) FROM single_replicatated WHERE key = 100; RESET client_min_messages;