blob: 867d550c7457002e47e046265ab664e7cee01de0 [file] [log] [blame]
-- Test for verifying if wal seg created while basebackup
-- dumps out data does not get cleaned
-- Inject fault after checkpoint creation in basebackup
SELECT gp_inject_fault('base_backup_post_create_checkpoint', 'suspend', dbid) FROM gp_segment_configuration WHERE content=-1 and role='p';
gp_inject_fault
-----------------
Success:
(1 row)
-- Run pg_basebackup which should trigger and suspend at the fault
1&: SELECT pg_basebackup(hostname, 100, port, false, NULL, '/tmp/master_wal_switch_test', true, 'fetch') from gp_segment_configuration where content=-1 and role='p'; <waiting ...>
-- Wait until fault has been triggered
SELECT gp_wait_until_triggered_fault('base_backup_post_create_checkpoint', 1, dbid) FROM gp_segment_configuration WHERE content=-1 and role='p';
gp_wait_until_triggered_fault
-------------------------------
Success:
(1 row)
-- See that pg_basebackup is still running
SELECT application_name, state FROM pg_stat_replication;
application_name | state
------------------+-----------
gp_walreceiver | streaming
pg_basebackup | backup
(2 rows)
-- Switch to a new WAL segment file. Two pg_switch_wal() invocations
-- with a command that generates WAL in between the invocations are
-- suffice to generate new WAL file.
CREATE TEMP TABLE walfile(fname text);
CREATE
INSERT INTO walfile SELECT pg_walfile_name(pg_switch_wal());
INSERT 1
CREATE TABLE master_wal_dummy();
CREATE
-- This should return false, indicating current WAL segment is
-- different than what was previously recorded walfile table.
SELECT fname = pg_walfile_name(pg_switch_wal()) FROM walfile;
?column?
----------
f
(1 row)
-- Checkpoint should retain WAL that is still needed by basebackup.
CHECKPOINT;
CHECKPOINT
-- Resume basebackup
SELECT gp_inject_fault('base_backup_post_create_checkpoint', 'reset', dbid) FROM gp_segment_configuration WHERE content=-1 and role='p';
gp_inject_fault
-----------------
Success:
(1 row)
-- Wait until basebackup finishes
1<: <... completed>
pg_basebackup
---------------
(1 row)
-- Verify if basebackup completed successfully
-- See if recovery.conf exists (Yes - Pass)
SELECT application_name, state FROM pg_stat_replication;
application_name | state
------------------+-----------
gp_walreceiver | streaming
(1 row)
!\retcode ls /tmp/master_wal_switch_test/postgresql.auto.conf /tmp/master_wal_switch_test/standby.signal;
-- start_ignore
/tmp/master_wal_switch_test/postgresql.auto.conf
/tmp/master_wal_switch_test/standby.signal
-- end_ignore
(exited with code 0)