|
25 | 25 | $node_master->safe_psql('postgres', "SELECT pg_create_physical_replication_slot('rep1')");
|
26 | 26 |
|
27 | 27 | # The slot state and remain should be null before the first connection
|
28 |
| -my $result = $node_master->safe_psql('postgres', "SELECT restart_lsn is NULL, wal_status is NULL, min_safe_lsn is NULL FROM pg_replication_slots WHERE slot_name = 'rep1'"); |
| 28 | +my $result = $node_master->safe_psql('postgres', "SELECT restart_lsn IS NULL, wal_status is NULL, min_safe_lsn is NULL FROM pg_replication_slots WHERE slot_name = 'rep1'"); |
29 | 29 | is($result, "t|t|t", 'check the state of non-reserved slot is "unknown"');
|
30 | 30 |
|
31 | 31 |
|
|
48 | 48 | $node_standby->stop;
|
49 | 49 |
|
50 | 50 | # Preparation done, the slot is the state "normal" now
|
51 |
| -$result = $node_master->safe_psql('postgres', "SELECT restart_lsn, wal_status, min_safe_lsn is NULL FROM pg_replication_slots WHERE slot_name = 'rep1'"); |
52 |
| -is($result, "$start_lsn|normal|t", 'check the catching-up state'); |
| 51 | +$result = $node_master->safe_psql('postgres', "SELECT wal_status, min_safe_lsn is NULL FROM pg_replication_slots WHERE slot_name = 'rep1'"); |
| 52 | +is($result, "normal|t", 'check the catching-up state'); |
53 | 53 |
|
54 | 54 | # Advance WAL by five segments (= 5MB) on master
|
55 | 55 | advance_wal($node_master, 1);
|
56 | 56 | $node_master->safe_psql('postgres', "CHECKPOINT;");
|
57 | 57 |
|
58 | 58 | # The slot is always "safe" when fitting max_wal_size
|
59 |
| -$result = $node_master->safe_psql('postgres', "SELECT restart_lsn, wal_status, min_safe_lsn is NULL FROM pg_replication_slots WHERE slot_name = 'rep1'"); |
60 |
| -is($result, "$start_lsn|normal|t", 'check that restart_lsn is in max_wal_size'); |
| 59 | +$result = $node_master->safe_psql('postgres', "SELECT wal_status, min_safe_lsn is NULL FROM pg_replication_slots WHERE slot_name = 'rep1'"); |
| 60 | +is($result, "normal|t", 'check that it is safe if WAL fits in max_wal_size'); |
61 | 61 |
|
62 | 62 | advance_wal($node_master, 4);
|
63 | 63 | $node_master->safe_psql('postgres', "CHECKPOINT;");
|
64 | 64 |
|
65 | 65 | # The slot is always "safe" when max_slot_wal_keep_size is not set
|
66 |
| -$result = $node_master->safe_psql('postgres', "SELECT restart_lsn, wal_status, min_safe_lsn is NULL FROM pg_replication_slots WHERE slot_name = 'rep1'"); |
67 |
| -is($result, "$start_lsn|normal|t", 'check that slot is working'); |
| 66 | +$result = $node_master->safe_psql('postgres', "SELECT wal_status, min_safe_lsn is NULL FROM pg_replication_slots WHERE slot_name = 'rep1'"); |
| 67 | +is($result, "normal|t", 'check that slot is working'); |
68 | 68 |
|
69 | 69 | # The standby can reconnect to master
|
70 | 70 | $node_standby->start;
|
|
85 | 85 | # be as almost (max_slot_wal_keep_size - 1) times large as the segment
|
86 | 86 | # size
|
87 | 87 |
|
88 |
| -$result = $node_master->safe_psql('postgres', "SELECT restart_lsn, wal_status, pg_size_pretty(pg_current_wal_lsn() - min_safe_lsn) FROM pg_replication_slots WHERE slot_name = 'rep1'"); |
89 |
| -is($result, "$start_lsn|normal|5120 kB", 'check that max_slot_wal_keep_size is working'); |
| 88 | +$result = $node_master->safe_psql('postgres', "SELECT wal_status FROM pg_replication_slots WHERE slot_name = 'rep1'"); |
| 89 | +is($result, "normal", 'check that max_slot_wal_keep_size is working'); |
90 | 90 |
|
91 | 91 | # Advance WAL again then checkpoint, reducing remain by 2 MB.
|
92 | 92 | advance_wal($node_master, 2);
|
93 | 93 | $node_master->safe_psql('postgres', "CHECKPOINT;");
|
94 | 94 |
|
95 | 95 | # The slot is still working
|
96 |
| -$result = $node_master->safe_psql('postgres', "SELECT restart_lsn, wal_status, pg_size_pretty(pg_current_wal_lsn() - min_safe_lsn) FROM pg_replication_slots WHERE slot_name = 'rep1'"); |
97 |
| -is($result, "$start_lsn|normal|2048 kB", 'check that min_safe_lsn gets close to the current LSN'); |
| 96 | +$result = $node_master->safe_psql('postgres', "SELECT wal_status FROM pg_replication_slots WHERE slot_name = 'rep1'"); |
| 97 | +is($result, "normal", 'check that min_safe_lsn gets close to the current LSN'); |
98 | 98 |
|
99 | 99 | # The standby can reconnect to master
|
100 | 100 | $node_standby->start;
|
|
106 | 106 | $result = $node_master->safe_psql('postgres', "ALTER SYSTEM SET wal_keep_segments to 8; SELECT pg_reload_conf();");
|
107 | 107 | # Advance WAL again then checkpoint, reducing remain by 6 MB.
|
108 | 108 | advance_wal($node_master, 6);
|
109 |
| -$result = $node_master->safe_psql('postgres', "SELECT restart_lsn, wal_status, pg_size_pretty(pg_current_wal_lsn() - min_safe_lsn) as remain FROM pg_replication_slots WHERE slot_name = 'rep1'"); |
110 |
| -is($result, "$start_lsn|normal|8192 kB", 'check that wal_keep_segments overrides max_slot_wal_keep_size'); |
| 109 | +$result = $node_master->safe_psql('postgres', "SELECT wal_status as remain FROM pg_replication_slots WHERE slot_name = 'rep1'"); |
| 110 | +is($result, "normal", 'check that wal_keep_segments overrides max_slot_wal_keep_size'); |
111 | 111 | # restore wal_keep_segments
|
112 | 112 | $result = $node_master->safe_psql('postgres', "ALTER SYSTEM SET wal_keep_segments to 0; SELECT pg_reload_conf();");
|
113 | 113 |
|
|
131 | 131 | advance_wal($node_master, 1);
|
132 | 132 |
|
133 | 133 | # Slot gets into 'lost' state
|
134 |
| -$result = $node_master->safe_psql('postgres', "SELECT wal_status FROM pg_replication_slots WHERE slot_name = 'rep1'"); |
135 |
| -is($result, "lost", 'check that the slot state changes to "lost"'); |
| 134 | +$result = $node_master->safe_psql('postgres', "SELECT wal_status, min_safe_lsn is NULL FROM pg_replication_slots WHERE slot_name = 'rep1'"); |
| 135 | +is($result, "lost|t", 'check that the slot state changes to "lost"'); |
136 | 136 |
|
137 | 137 | # The standby still can connect to master before a checkpoint
|
138 | 138 | $node_standby->start;
|
|
158 | 158 | 'check that the warning is logged');
|
159 | 159 |
|
160 | 160 | # This slot should be broken
|
161 |
| -$result = $node_master->safe_psql('postgres', "SELECT slot_name, active, restart_lsn, wal_status, min_safe_lsn FROM pg_replication_slots WHERE slot_name = 'rep1'"); |
162 |
| -is($result, "rep1|f|||", 'check that the slot became inactive'); |
| 161 | +$result = $node_master->safe_psql('postgres', "SELECT slot_name, active, restart_lsn IS NULL, wal_status, min_safe_lsn FROM pg_replication_slots WHERE slot_name = 'rep1'"); |
| 162 | +is($result, "rep1|f|t||", 'check that the slot became inactive'); |
163 | 163 |
|
164 | 164 | # The standby no longer can connect to the master
|
165 | 165 | $logstart = get_log_size($node_standby);
|
|
0 commit comments