|
30 | 30 | my $psql_rc = '';
|
31 | 31 |
|
32 | 32 | ###############################################################################
|
33 |
| -# Check that we can commit and abort after soft restart. |
| 33 | +# Check that we can commit and abort tx after soft restart. |
34 | 34 | # Here checkpoint happens before shutdown and no WAL replay will not occur
|
35 |
| -# during start. So code should re-create memory state from files. |
| 35 | +# during start. So postgres should re-create memory state from files. |
36 | 36 | ###############################################################################
|
37 | 37 |
|
38 | 38 | $node_master->psql('postgres', "
|
|
54 | 54 | ###############################################################################
|
55 | 55 | # Check that we can commit and abort after hard restart.
|
56 | 56 | # On startup WAL replay will re-create memory for global transactions that
|
57 |
| -# happend after last checkpoint and stored. |
| 57 | +# happend after the last checkpoint. |
58 | 58 | ###############################################################################
|
59 | 59 |
|
60 | 60 | $node_master->psql('postgres', "
|
| 61 | + checkpoint; |
61 | 62 | begin;
|
62 | 63 | insert into t values (42);
|
63 | 64 | prepare transaction 'x';
|
|
78 | 79 | ###############################################################################
|
79 | 80 |
|
80 | 81 | $node_master->psql('postgres', "
|
| 82 | + checkpoint; |
81 | 83 | begin;
|
82 | 84 | insert into t values (42);
|
83 | 85 | prepare transaction 'x';
|
|
89 | 91 | $node_master->start;
|
90 | 92 |
|
91 | 93 | $psql_rc = $node_master->psql('postgres', "commit prepared 'x'");
|
92 |
| -is($psql_rc, '0', 'Check that we can replay several tx with same name.'); |
| 94 | +is($psql_rc, '0', 'Replay several tx with same name.'); |
93 | 95 |
|
94 | 96 | ###############################################################################
|
95 | 97 | # Check that WAL replay will cleanup it's memory state and release locks while
|
|
107 | 109 | begin;
|
108 | 110 | insert into t values (42);
|
109 | 111 | -- This prepare can fail due to 2pc identifier or locks conflicts if replay
|
110 |
| - -- didn't cleanup proc, gxact or locks on commit. |
| 112 | + -- didn't fully cleanup it's state on commit. |
111 | 113 | prepare transaction 'x';");
|
112 |
| -is($psql_rc, '0', "Check that WAL replay will cleanup it's memory state"); |
| 114 | +is($psql_rc, '0', "Check that replay will cleanup it's memory state"); |
| 115 | + |
113 | 116 | $node_master->psql('postgres', "commit prepared 'x'");
|
114 | 117 |
|
115 | 118 | ###############################################################################
|
116 |
| -# Check that we can commit while running active sync slave and that there is no |
117 |
| -# active prepared transaction on slave after that. |
| 119 | +# Check that WAL replay will cleanup it's memory state on running slave. |
118 | 120 | ###############################################################################
|
119 | 121 |
|
120 | 122 | $node_master->psql('postgres', "
|
|
124 | 126 | commit prepared 'x';
|
125 | 127 | ");
|
126 | 128 | $node_slave->psql('postgres', "select count(*) from pg_prepared_xacts;", stdout => \$psql_out);
|
127 |
| -is($psql_out, '0', "Check that WAL replay will cleanup it's memory state on slave"); |
| 129 | +is($psql_out, '0', "Check that replay will cleanup it's memory state on running slave"); |
128 | 130 |
|
129 | 131 | ###############################################################################
|
130 | 132 | # The same as in previous case, but let's force checkpoint on slave between
|
|
139 | 141 | $node_slave->psql('postgres',"checkpoint;");
|
140 | 142 | $node_master->psql('postgres', "commit prepared 'x';");
|
141 | 143 | $node_slave->psql('postgres', "select count(*) from pg_prepared_xacts;", stdout => \$psql_out);
|
142 |
| -is($psql_out, '0', "Check that WAL replay will cleanup it's memory state on slave after checkpoint"); |
| 144 | +is($psql_out, '0', "Check that replay will cleanup it's memory state on slave after checkpoint"); |
143 | 145 |
|
144 | 146 | ###############################################################################
|
145 | 147 | # Check that we can commit transaction on promoted slave.
|
|
153 | 155 | $node_master->teardown_node;
|
154 | 156 | $node_slave->promote;
|
155 | 157 | $node_slave->poll_query_until('postgres', "SELECT pg_is_in_recovery() <> true");
|
| 158 | + |
156 | 159 | $psql_rc = $node_slave->psql('postgres', "commit prepared 'x';");
|
157 |
| -is($psql_rc, '0', "Check that we can commit transaction on promoted slave."); |
| 160 | +is($psql_rc, '0', "Restore prepared transaction on promoted slave."); |
158 | 161 |
|
159 | 162 | # change roles
|
160 | 163 | ($node_master, $node_slave) = ($node_slave, $node_master);
|
|
166 | 169 |
|
167 | 170 | ###############################################################################
|
168 | 171 | # Check that we restore prepared xacts after slave soft restart while master is
|
169 |
| -# down. |
| 172 | +# down. Since slave knows that master is down it uses different code path on |
| 173 | +# start. |
170 | 174 | ###############################################################################
|
171 | 175 |
|
172 | 176 | $node_master->psql('postgres', "
|
|
178 | 182 | $node_slave->restart;
|
179 | 183 | $node_slave->promote;
|
180 | 184 | $node_slave->poll_query_until('postgres', "SELECT pg_is_in_recovery() <> true");
|
| 185 | + |
181 | 186 | $node_slave->psql('postgres',"select count(*) from pg_prepared_xacts", stdout => \$psql_out);
|
182 |
| -is($psql_out, '1', "Check that we restore prepared xacts after slave soft restart while master is down."); |
| 187 | +is($psql_out, '1', "Restore prepared xacts after slave soft restart while master is down."); |
183 | 188 |
|
184 | 189 | # restore state
|
185 | 190 | ($node_master, $node_slave) = ($node_slave, $node_master);
|
|
205 | 210 | $node_slave->start;
|
206 | 211 | $node_slave->promote;
|
207 | 212 | $node_slave->poll_query_until('postgres', "SELECT pg_is_in_recovery() <> true");
|
| 213 | + |
208 | 214 | $node_slave->psql('postgres',"select count(*) from pg_prepared_xacts", stdout => \$psql_out);
|
209 |
| -is($psql_out, '1', "Check that we restore prepared xacts after slave hard restart while master is down."); |
| 215 | +is($psql_out, '1', "Restore prepared xacts after slave hard restart while master is down."); |
210 | 216 |
|
211 | 217 | # restore state
|
212 | 218 | ($node_master, $node_slave) = ($node_slave, $node_master);
|
|
0 commit comments