diff --git a/src/backend/replication/gp_replication.c b/src/backend/replication/gp_replication.c index 59457fdea94158478f939b88b777c2c5077f37ba..2dcc8cbd686c0d1a9151e0879642ff587da01c93 100644 --- a/src/backend/replication/gp_replication.c +++ b/src/backend/replication/gp_replication.c @@ -291,10 +291,13 @@ FTSReplicationStatusMarkDisconnectForReplication(const char *app_name) LWLockAcquire(FTSReplicationStatusLock, LW_SHARED); - replication_status = RetrieveFTSReplicationStatus(app_name, false /* skip_warn */); + /* + * FTS may already mark the mirror down and free the replication status. + * For this case, a NULL pointer will return. + */ + replication_status = RetrieveFTSReplicationStatus(app_name, true /* skip_warn */); - /* replication_status must exist */ - Assert(replication_status); + /* if replication_status is NULL, do nothing */ FTSReplicationStatusMarkDisconnect(replication_status); LWLockRelease(FTSReplicationStatusLock); diff --git a/src/test/isolation2/expected/segwalrep/replication_keeps_crash.out b/src/test/isolation2/expected/segwalrep/replication_keeps_crash.out index 01039af38ca3215ade5039c1e1cc91092d11d590..6f0aec6f3be3735e76e701f0878a6ca661c88d76 100644 --- a/src/test/isolation2/expected/segwalrep/replication_keeps_crash.out +++ b/src/test/isolation2/expected/segwalrep/replication_keeps_crash.out @@ -15,8 +15,6 @@ CREATE -- modify fts gucs to speed up the test. 1: alter system set gp_fts_probe_interval to 10; ALTER -1: alter system set gp_fts_probe_retries to 1; -ALTER 1: alter system set gp_fts_replication_attempt_count to 3; ALTER 1: select pg_reload_conf(); @@ -49,6 +47,12 @@ select gp_inject_fault_infinite('wal_sender_loop', 'error', dbid) from gp_segmen -- LSN to be flushed on mirror. 1&: create table mirror_block_t1 (a int) distributed by (a); +select gp_wait_until_triggered_fault('wal_sender_loop', 1, dbid) from gp_segment_configuration where role='p' and content=0; + gp_wait_until_triggered_fault +------------------------------- + Success: +(1 row) + -- trigger fts to mark mirror down. select gp_request_fts_probe_scan(); gp_request_fts_probe_scan @@ -108,8 +112,6 @@ DROP 1: alter system reset gp_fts_probe_interval; ALTER -1: alter system reset gp_fts_probe_retries; -ALTER 1: alter system reset gp_fts_replication_attempt_count; ALTER 1: select pg_reload_conf(); diff --git a/src/test/isolation2/sql/segwalrep/replication_keeps_crash.sql b/src/test/isolation2/sql/segwalrep/replication_keeps_crash.sql index 9439f6ce201a088feac6765b5c2b995edb3f23ca..ec36a360ec14bd699f815255a362a7bfab16d366 100644 --- a/src/test/isolation2/sql/segwalrep/replication_keeps_crash.sql +++ b/src/test/isolation2/sql/segwalrep/replication_keeps_crash.sql @@ -13,7 +13,6 @@ include: helpers/server_helpers.sql; -- modify fts gucs to speed up the test. 1: alter system set gp_fts_probe_interval to 10; -1: alter system set gp_fts_probe_retries to 1; 1: alter system set gp_fts_replication_attempt_count to 3; 1: select pg_reload_conf(); @@ -27,6 +26,8 @@ select gp_inject_fault_infinite('wal_sender_loop', 'error', dbid) -- LSN to be flushed on mirror. 1&: create table mirror_block_t1 (a int) distributed by (a); +select gp_wait_until_triggered_fault('wal_sender_loop', 1, dbid) from gp_segment_configuration where role='p' and content=0; + -- trigger fts to mark mirror down. select gp_request_fts_probe_scan(); @@ -55,6 +56,5 @@ SELECT role, preferred_role, content, mode, status FROM gp_segment_configuration drop table mirror_block_t1; 1: alter system reset gp_fts_probe_interval; -1: alter system reset gp_fts_probe_retries; 1: alter system reset gp_fts_replication_attempt_count; 1: select pg_reload_conf();