Skip to content

Commit

Permalink
Fix flaky multi_mx_node_metadata.sql test
Browse files Browse the repository at this point in the history
  • Loading branch information
onurctirtir committed Nov 1, 2023
1 parent e3c93c3 commit 80baf66
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 6 deletions.
8 changes: 8 additions & 0 deletions src/test/regress/citus_tests/run_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,14 @@ def extra_tests(self):
"grant_on_schema_propagation": TestDeps("minimal_schedule"),
"propagate_extension_commands": TestDeps("minimal_schedule"),
"multi_size_queries": TestDeps("base_schedule", ["multi_copy"]),
"multi_mx_node_metadata": TestDeps(
None,
[
"multi_extension",
"multi_test_helpers",
"multi_test_helpers_superuser",
],
),
}


Expand Down
21 changes: 18 additions & 3 deletions src/test/regress/expected/multi_mx_node_metadata.out
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ SET citus.shard_count TO 8;
SET citus.shard_replication_factor TO 1;
\set VERBOSITY terse
-- Simulates a readonly node by setting default_transaction_read_only.
CREATE FUNCTION mark_node_readonly(hostname TEXT, port INTEGER, isreadonly BOOLEAN)
CREATE OR REPLACE FUNCTION mark_node_readonly(hostname TEXT, port INTEGER, isreadonly BOOLEAN)
RETURNS TEXT
LANGUAGE sql
AS $$
Expand All @@ -27,7 +27,7 @@ CREATE OR REPLACE FUNCTION raise_error_in_metadata_sync()
RETURNS void
LANGUAGE C STRICT
AS 'citus';
CREATE PROCEDURE wait_until_process_count(appname text, target_count int) AS $$
CREATE OR REPLACE PROCEDURE wait_until_process_count(appname text, target_count int) AS $$
declare
counter integer := -1;
begin
Expand Down Expand Up @@ -846,7 +846,22 @@ SELECT datname FROM pg_stat_activity WHERE application_name LIKE 'Citus Met%';
db_to_drop
(1 row)

DROP DATABASE db_to_drop;
DO $$
DECLARE
i int := 0;
BEGIN
WHILE NOT (SELECT bool_and(success) from run_command_on_all_nodes('DROP DATABASE IF EXISTS db_to_drop'))
LOOP
BEGIN
i := i + 1;
IF i > 5 THEN
RAISE EXCEPTION 'DROP DATABASE timed out';
END IF;
PERFORM pg_sleep(1);
END;
END LOOP;
END;
$$;
SELECT datname FROM pg_stat_activity WHERE application_name LIKE 'Citus Met%';
datname
---------------------------------------------------------------------
Expand Down
21 changes: 18 additions & 3 deletions src/test/regress/sql/multi_mx_node_metadata.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ SET citus.shard_replication_factor TO 1;
\set VERBOSITY terse

-- Simulates a readonly node by setting default_transaction_read_only.
CREATE FUNCTION mark_node_readonly(hostname TEXT, port INTEGER, isreadonly BOOLEAN)
CREATE OR REPLACE FUNCTION mark_node_readonly(hostname TEXT, port INTEGER, isreadonly BOOLEAN)
RETURNS TEXT
LANGUAGE sql
AS $$
Expand All @@ -35,7 +35,7 @@ CREATE OR REPLACE FUNCTION raise_error_in_metadata_sync()
LANGUAGE C STRICT
AS 'citus';

CREATE PROCEDURE wait_until_process_count(appname text, target_count int) AS $$
CREATE OR REPLACE PROCEDURE wait_until_process_count(appname text, target_count int) AS $$
declare
counter integer := -1;
begin
Expand Down Expand Up @@ -378,7 +378,22 @@ SELECT trigger_metadata_sync();

SELECT datname FROM pg_stat_activity WHERE application_name LIKE 'Citus Met%';

DROP DATABASE db_to_drop;
DO $$
DECLARE
i int := 0;
BEGIN
WHILE NOT (SELECT bool_and(success) from run_command_on_all_nodes('DROP DATABASE IF EXISTS db_to_drop'))
LOOP
BEGIN
i := i + 1;
IF i > 5 THEN
RAISE EXCEPTION 'DROP DATABASE timed out';
END IF;
PERFORM pg_sleep(1);
END;
END LOOP;
END;
$$;

SELECT datname FROM pg_stat_activity WHERE application_name LIKE 'Citus Met%';

Expand Down

0 comments on commit 80baf66

Please sign in to comment.