|
28 | 28 |
|
29 | 29 | # The slot state and remain should be null before the first connection
|
30 | 30 | my $result = $node_master->safe_psql('postgres',
|
31 |
| - "SELECT restart_lsn IS NULL, wal_status is NULL, min_safe_lsn is NULL FROM pg_replication_slots WHERE slot_name = 'rep1'" |
| 31 | + "SELECT restart_lsn IS NULL, wal_status is NULL, safe_wal_size is NULL FROM pg_replication_slots WHERE slot_name = 'rep1'" |
32 | 32 | );
|
33 | 33 | is($result, "t|t|t", 'check the state of non-reserved slot is "unknown"');
|
34 | 34 |
|
|
52 | 52 | # Stop standby
|
53 | 53 | $node_standby->stop;
|
54 | 54 |
|
55 |
| -# Preparation done, the slot is the state "normal" now |
| 55 | +# Preparation done, the slot is the state "reserved" now |
56 | 56 | $result = $node_master->safe_psql('postgres',
|
57 |
| - "SELECT wal_status, min_safe_lsn is NULL FROM pg_replication_slots WHERE slot_name = 'rep1'" |
| 57 | + "SELECT wal_status, safe_wal_size IS NULL FROM pg_replication_slots WHERE slot_name = 'rep1'" |
58 | 58 | );
|
59 | 59 | is($result, "reserved|t", 'check the catching-up state');
|
60 | 60 |
|
|
64 | 64 |
|
65 | 65 | # The slot is always "safe" when fitting max_wal_size
|
66 | 66 | $result = $node_master->safe_psql('postgres',
|
67 |
| - "SELECT wal_status, min_safe_lsn is NULL FROM pg_replication_slots WHERE slot_name = 'rep1'" |
| 67 | + "SELECT wal_status, safe_wal_size IS NULL FROM pg_replication_slots WHERE slot_name = 'rep1'" |
68 | 68 | );
|
69 | 69 | is($result, "reserved|t",
|
70 | 70 | 'check that it is safe if WAL fits in max_wal_size');
|
|
74 | 74 |
|
75 | 75 | # The slot is always "safe" when max_slot_wal_keep_size is not set
|
76 | 76 | $result = $node_master->safe_psql('postgres',
|
77 |
| - "SELECT wal_status, min_safe_lsn is NULL FROM pg_replication_slots WHERE slot_name = 'rep1'" |
| 77 | + "SELECT wal_status, safe_wal_size IS NULL FROM pg_replication_slots WHERE slot_name = 'rep1'" |
78 | 78 | );
|
79 | 79 | is($result, "reserved|t", 'check that slot is working');
|
80 | 80 |
|
|
94 | 94 | ));
|
95 | 95 | $node_master->reload;
|
96 | 96 |
|
97 |
| -# The slot is in safe state. The distance from the min_safe_lsn should |
98 |
| -# be as almost (max_slot_wal_keep_size - 1) times large as the segment |
99 |
| -# size |
| 97 | +# The slot is in safe state. |
100 | 98 |
|
101 | 99 | $result = $node_master->safe_psql('postgres',
|
102 | 100 | "SELECT wal_status FROM pg_replication_slots WHERE slot_name = 'rep1'");
|
|
110 | 108 | $result = $node_master->safe_psql('postgres',
|
111 | 109 | "SELECT wal_status FROM pg_replication_slots WHERE slot_name = 'rep1'");
|
112 | 110 | is($result, "reserved",
|
113 |
| - 'check that min_safe_lsn gets close to the current LSN'); |
| 111 | + 'check that safe_wal_size gets close to the current LSN'); |
114 | 112 |
|
115 | 113 | # The standby can reconnect to master
|
116 | 114 | $node_standby->start;
|
|
152 | 150 | # Advance WAL again without checkpoint; remain goes to 0.
|
153 | 151 | advance_wal($node_master, 1);
|
154 | 152 |
|
155 |
| -# Slot gets into 'unreserved' state |
| 153 | +# Slot gets into 'unreserved' state and safe_wal_size is negative |
156 | 154 | $result = $node_master->safe_psql('postgres',
|
157 |
| - "SELECT wal_status, min_safe_lsn is NULL FROM pg_replication_slots WHERE slot_name = 'rep1'" |
| 155 | + "SELECT wal_status, safe_wal_size <= 0 FROM pg_replication_slots WHERE slot_name = 'rep1'" |
158 | 156 | );
|
159 | 157 | is($result, "unreserved|t",
|
160 | 158 | 'check that the slot state changes to "unreserved"');
|
|
186 | 184 |
|
187 | 185 | # This slot should be broken
|
188 | 186 | $result = $node_master->safe_psql('postgres',
|
189 |
| - "SELECT slot_name, active, restart_lsn IS NULL, wal_status, min_safe_lsn FROM pg_replication_slots WHERE slot_name = 'rep1'" |
| 187 | + "SELECT slot_name, active, restart_lsn IS NULL, wal_status, safe_wal_size FROM pg_replication_slots WHERE slot_name = 'rep1'" |
190 | 188 | );
|
191 | 189 | is($result, "rep1|f|t|lost|",
|
192 | 190 | 'check that the slot became inactive and the state "lost" persists');
|
|
0 commit comments