| -- This test assumes 3 primaries and 3 mirrors from a gpdemo segwalrep cluster |
| |
| -- make sure we are in-sync for the primary we will be testing with |
| select content, role, preferred_role, status from gp_segment_configuration; |
| content | role | preferred_role | status |
| ---------+------+----------------+-------- |
| -1 | p | p | u |
| -1 | m | m | u |
| 1 | p | p | u |
| 1 | m | m | u |
| 2 | p | p | u |
| 2 | m | m | u |
| 0 | p | p | u |
| 0 | m | m | u |
| (8 rows) |
| |
| -- print synchronous_standby_names should be set to '*' at start of test |
| 0U: show synchronous_standby_names; |
| synchronous_standby_names |
| --------------------------- |
| * |
| (1 row) |
| |
| -- create table and show commits are not blocked |
| create table segwalrep_commit_blocking (a int) distributed by (a); |
| CREATE |
| insert into segwalrep_commit_blocking values (5); |
| INSERT 1 |
| |
| -- skip FTS probes always |
| select gp_inject_fault('fts_probe', 'reset', 1); |
| gp_inject_fault |
| ----------------- |
| Success: |
| (1 row) |
| select gp_inject_fault_infinite('fts_probe', 'skip', 1); |
| gp_inject_fault_infinite |
| -------------------------- |
| Success: |
| (1 row) |
| -- force scan to trigger the fault |
| select gp_request_fts_probe_scan(); |
| gp_request_fts_probe_scan |
| --------------------------- |
| t |
| (1 row) |
| !\retcode gpfts -A -D; |
| -- start_ignore |
| |
| -- end_ignore |
| (exited with code 0) |
| |
| -- 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'); |
| pg_ctl |
| -------- |
| OK |
| (1 row) |
| -- We should insert a tuple to segment 0. |
| -- With jump consistent hash as the underlying hash algorithm, |
| -- a int value of 4 is on seg0. |
| 0U&: insert into segwalrep_commit_blocking values (4); <waiting ...> |
| |
| -- restart primary dbid 2 |
| -1U: select pg_ctl((select datadir from gp_segment_configuration c where c.role='p' and c.content=0), 'restart'); |
| pg_ctl |
| -------- |
| OK |
| (1 row) |
| |
| -- should show dbid 2 utility mode connection closed because of primary restart |
| 0U<: <... completed> |
| server closed the connection unexpectedly |
| This probably means the server terminated abnormally |
| before or while processing the request. |
| 0Uq: ... <quitting> |
| |
| -- synchronous_standby_names should be set to '*' after primary restart |
| 0U: show synchronous_standby_names; |
| synchronous_standby_names |
| --------------------------- |
| * |
| (1 row) |
| |
| -- this should block since mirror is not up and sync replication is on |
| 3: begin; |
| BEGIN |
| 3: insert into segwalrep_commit_blocking values (4); |
| INSERT 1 |
| 3&: commit; <waiting ...> |
| |
| -- this should not block due to direct dispatch to primary with active synced mirror |
| 4: insert into segwalrep_commit_blocking values (6); |
| INSERT 1 |
| |
| -- bring the mirror back up |
| -1U: select pg_ctl_start(datadir, port) from gp_segment_configuration where role = 'm' and content = 0; |
| pg_ctl_start |
| -------------------------------------------------- |
| |
| waiting for server to start done |
| server started |
| (1 row) |
| |
| -- should unblock and commit now that mirror is back up and in-sync |
| 3<: <... completed> |
| COMMIT |
| |
| -- resume FTS probes |
| select gp_inject_fault('fts_probe', 'reset', 1); |
| gp_inject_fault |
| ----------------- |
| Success: |
| (1 row) |
| |
| -- everything should be back to normal |
| 4: insert into segwalrep_commit_blocking select i from generate_series(1,10)i; |
| INSERT 10 |
| 4: select * from segwalrep_commit_blocking order by a; |
| a |
| ---- |
| 1 |
| 2 |
| 3 |
| 4 |
| 4 |
| 4 |
| 5 |
| 5 |
| 6 |
| 6 |
| 7 |
| 8 |
| 9 |
| 10 |
| (14 rows) |