From aeec7baf68d1b7a0031beaff4afa1ce88d98b264 Mon Sep 17 00:00:00 2001 From: Ashwin Agrawal Date: Tue, 27 Mar 2018 16:12:38 -0700 Subject: [PATCH] Test should pass correct gp_dbid when starting segments. Not passing the right gp_dbid, caused test running after these test to fail, as gp_inject_fault checks dbid to set the fault or not. If segment was started with gp_dbid=0, the fault fails to set in other tests causing failures. --- .../expected/segwalrep/commit_blocking.out | 10 ++++------ .../expected/segwalrep/fts_unblock_primary.out | 8 +++----- .../isolation2/sql/segwalrep/commit_blocking.sql | 12 +++++------- .../isolation2/sql/segwalrep/fts_unblock_primary.sql | 10 ++++------ 4 files changed, 16 insertions(+), 24 deletions(-) diff --git a/src/test/isolation2/expected/segwalrep/commit_blocking.out b/src/test/isolation2/expected/segwalrep/commit_blocking.out index 25946cb5b4..acdc9fc77b 100644 --- a/src/test/isolation2/expected/segwalrep/commit_blocking.out +++ b/src/test/isolation2/expected/segwalrep/commit_blocking.out @@ -5,9 +5,7 @@ create language plpythonu; CREATE -- end_ignore -create or replace function pg_ctl(datadir text, command text, port int, contentid int) returns text as $$ import subprocess -cmd = 'pg_ctl -D %s ' % datadir if command in ('stop', 'restart'): cmd = cmd + '-w -m immediate %s' % command elif command == 'start': opts = '-p %d -\-gp_dbid=0 -\-silent-mode=true -i -\-gp_contentid=%d -\-gp_num_contents_in_cluster=3' % (port, contentid) cmd = cmd + '-o "%s" start' % opts else: return 'Invalid command input' -return subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).replace('.', '') $$ language plpythonu; +create or replace function pg_ctl(datadir text, command text, port int, contentid int, dbid int) returns text as $$ import subprocess cmd = 'pg_ctl -D %s ' % datadir if command in ('stop', 'restart'): cmd = cmd + '-w -m immediate %s' % command elif command == 'start': opts = '-p %d -\-gp_dbid=%d -\-silent-mode=true -i -\-gp_contentid=%d -\-gp_num_contents_in_cluster=3' % (port, dbid, contentid) cmd = cmd + '-o "%s" start' % opts else: return 'Invalid command input' return subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).replace('.', '') $$ language plpythonu; CREATE -- make sure we are in-sync for the primary we will be testing with @@ -58,7 +56,7 @@ t (1 row) -- stop a mirror and show commit on dbid 2 will block --1U: select pg_ctl((select datadir from gp_segment_configuration c where c.role='m' and c.content=0), 'stop', NULL, NULL); +-1U: select pg_ctl((select datadir from gp_segment_configuration c where c.role='m' and c.content=0), 'stop', NULL, NULL, NULL); pg_ctl ---------------------------------------------------- waiting for server to shut down done @@ -68,7 +66,7 @@ server stopped 0U&: insert into segwalrep_commit_blocking values (1); -- restart primary dbid 2 --1U: select pg_ctl((select datadir from gp_segment_configuration c where c.role='p' and c.content=0), 'restart', NULL, NULL); +-1U: select pg_ctl((select datadir from gp_segment_configuration c where c.role='p' and c.content=0), 'restart', NULL, NULL, NULL); pg_ctl ---------------------------------------------------------------------------------------------------- waiting for server to shut down done @@ -104,7 +102,7 @@ INSERT 1 INSERT 1 -- bring the mirror back up --1U: select pg_ctl((select datadir from gp_segment_configuration c where c.role='m' and c.content=0), 'start', (select port from gp_segment_configuration where content = 0 and preferred_role = 'm'), 0); +-1U: select pg_ctl((select datadir from gp_segment_configuration c where c.role='m' and c.content=0), 'start', (select port from gp_segment_configuration where content = 0 and preferred_role = 'm'), 0, (select dbid from gp_segment_configuration c where c.role='m' and c.content=0)); pg_ctl ---------------- server starting diff --git a/src/test/isolation2/expected/segwalrep/fts_unblock_primary.out b/src/test/isolation2/expected/segwalrep/fts_unblock_primary.out index 0e2196cf83..175d84c5fc 100644 --- a/src/test/isolation2/expected/segwalrep/fts_unblock_primary.out +++ b/src/test/isolation2/expected/segwalrep/fts_unblock_primary.out @@ -9,9 +9,7 @@ create language plpythonu; CREATE -- end_ignore -create or replace function pg_ctl(datadir text, command text, port int, contentid int) returns text as $$ import subprocess -cmd = 'pg_ctl -D %s ' % datadir if command in ('stop', 'restart'): cmd = cmd + '-w -m immediate %s' % command elif command == 'start': opts = '-p %d -\-gp_dbid=0 -\-silent-mode=true -i -\-gp_contentid=%d -\-gp_num_contents_in_cluster=3' % (port, contentid) cmd = cmd + '-o "%s" start' % opts else: return 'Invalid command input' -return subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).replace('.', '') $$ language plpythonu; +create or replace function pg_ctl(datadir text, command text, port int, contentid int, dbid int) returns text as $$ import subprocess cmd = 'pg_ctl -D %s ' % datadir if command in ('stop', 'restart'): cmd = cmd + '-w -m immediate %s' % command elif command == 'start': opts = '-p %d -\-gp_dbid=%d -\-silent-mode=true -i -\-gp_contentid=%d -\-gp_num_contents_in_cluster=3' % (port, dbid, contentid) cmd = cmd + '-o "%s" start' % opts else: return 'Invalid command input' return subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).replace('.', '') $$ language plpythonu; CREATE -- make sure we are in-sync for the primary we will be testing with @@ -68,7 +66,7 @@ t (1 row) -- stop a mirror --1U: select pg_ctl((select datadir from gp_segment_configuration c where c.role='m' and c.content=2), 'stop', NULL, NULL); +-1U: select pg_ctl((select datadir from gp_segment_configuration c where c.role='m' and c.content=2), 'stop', NULL, NULL, NULL); pg_ctl ---------------------------------------------------- waiting for server to shut down done @@ -149,7 +147,7 @@ synchronous_standby_names (1 row) -- bring the mirror back up and see primary s/u and mirror s/u --1U: select pg_ctl((select datadir from gp_segment_configuration c where c.role='m' and c.content=2), 'start', (select port from gp_segment_configuration where content = 2 and preferred_role = 'm'), 2); +-1U: select pg_ctl((select datadir from gp_segment_configuration c where c.role='m' and c.content=2), 'start', (select port from gp_segment_configuration where content = 2 and preferred_role = 'm'), 2, (select dbid from gp_segment_configuration c where c.role='m' and c.content=2)); pg_ctl ---------------- server starting diff --git a/src/test/isolation2/sql/segwalrep/commit_blocking.sql b/src/test/isolation2/sql/segwalrep/commit_blocking.sql index e620686f8e..cc3078572e 100644 --- a/src/test/isolation2/sql/segwalrep/commit_blocking.sql +++ b/src/test/isolation2/sql/segwalrep/commit_blocking.sql @@ -4,19 +4,17 @@ create language plpythonu; -- end_ignore -create or replace function pg_ctl(datadir text, command text, port int, contentid int) +create or replace function pg_ctl(datadir text, command text, port int, contentid int, dbid int) returns text as $$ import subprocess - cmd = 'pg_ctl -D %s ' % datadir if command in ('stop', 'restart'): cmd = cmd + '-w -m immediate %s' % command elif command == 'start': - opts = '-p %d -\-gp_dbid=0 -\-silent-mode=true -i -\-gp_contentid=%d -\-gp_num_contents_in_cluster=3' % (port, contentid) + opts = '-p %d -\-gp_dbid=%d -\-silent-mode=true -i -\-gp_contentid=%d -\-gp_num_contents_in_cluster=3' % (port, dbid, contentid) cmd = cmd + '-o "%s" start' % opts else: return 'Invalid command input' - return subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).replace('.', '') $$ language plpythonu; @@ -40,11 +38,11 @@ select gp_request_fts_probe_scan(); select gp_inject_fault('fts_probe', 'status', 1); -- stop a mirror and show commit on dbid 2 will block --1U: select pg_ctl((select datadir from gp_segment_configuration c where c.role='m' and c.content=0), 'stop', NULL, NULL); +-1U: select pg_ctl((select datadir from gp_segment_configuration c where c.role='m' and c.content=0), 'stop', NULL, NULL, NULL); 0U&: insert into segwalrep_commit_blocking values (1); -- restart primary dbid 2 --1U: select pg_ctl((select datadir from gp_segment_configuration c where c.role='p' and c.content=0), 'restart', NULL, NULL); +-1U: select pg_ctl((select datadir from gp_segment_configuration c where c.role='p' and c.content=0), 'restart', NULL, NULL, NULL); -- should show dbid 2 utility mode connection closed because of primary restart 0U<: @@ -62,7 +60,7 @@ select gp_inject_fault('fts_probe', 'status', 1); 4: insert into segwalrep_commit_blocking values (3); -- bring the mirror back up --1U: select pg_ctl((select datadir from gp_segment_configuration c where c.role='m' and c.content=0), 'start', (select port from gp_segment_configuration where content = 0 and preferred_role = 'm'), 0); +-1U: select pg_ctl((select datadir from gp_segment_configuration c where c.role='m' and c.content=0), 'start', (select port from gp_segment_configuration where content = 0 and preferred_role = 'm'), 0, (select dbid from gp_segment_configuration c where c.role='m' and c.content=0)); -- should unblock and commit now that mirror is back up and in-sync 3<: diff --git a/src/test/isolation2/sql/segwalrep/fts_unblock_primary.sql b/src/test/isolation2/sql/segwalrep/fts_unblock_primary.sql index 5a9387324d..76f6621c7f 100644 --- a/src/test/isolation2/sql/segwalrep/fts_unblock_primary.sql +++ b/src/test/isolation2/sql/segwalrep/fts_unblock_primary.sql @@ -21,19 +21,17 @@ $$ language plpgsql; create language plpythonu; -- end_ignore -create or replace function pg_ctl(datadir text, command text, port int, contentid int) +create or replace function pg_ctl(datadir text, command text, port int, contentid int, dbid int) returns text as $$ import subprocess - cmd = 'pg_ctl -D %s ' % datadir if command in ('stop', 'restart'): cmd = cmd + '-w -m immediate %s' % command elif command == 'start': - opts = '-p %d -\-gp_dbid=0 -\-silent-mode=true -i -\-gp_contentid=%d -\-gp_num_contents_in_cluster=3' % (port, contentid) + opts = '-p %d -\-gp_dbid=%d -\-silent-mode=true -i -\-gp_contentid=%d -\-gp_num_contents_in_cluster=3' % (port, dbid, contentid) cmd = cmd + '-o "%s" start' % opts else: return 'Invalid command input' - return subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).replace('.', '') $$ language plpythonu; @@ -59,7 +57,7 @@ select gp_request_fts_probe_scan(); select gp_inject_fault('fts_probe', 'status', 1); -- stop a mirror --1U: select pg_ctl((select datadir from gp_segment_configuration c where c.role='m' and c.content=2), 'stop', NULL, NULL); +-1U: select pg_ctl((select datadir from gp_segment_configuration c where c.role='m' and c.content=2), 'stop', NULL, NULL, NULL); -- this should block since mirror is not up and sync replication is on 2: begin; @@ -94,7 +92,7 @@ select content, role, preferred_role, mode, status from gp_segment_configuration 2U: show synchronous_standby_names; -- bring the mirror back up and see primary s/u and mirror s/u --1U: select pg_ctl((select datadir from gp_segment_configuration c where c.role='m' and c.content=2), 'start', (select port from gp_segment_configuration where content = 2 and preferred_role = 'm'), 2); +-1U: select pg_ctl((select datadir from gp_segment_configuration c where c.role='m' and c.content=2), 'start', (select port from gp_segment_configuration where content = 2 and preferred_role = 'm'), 2, (select dbid from gp_segment_configuration c where c.role='m' and c.content=2)); select wait_for_streaming(2::smallint); select content, role, preferred_role, mode, status from gp_segment_configuration where content=2; -- GitLab