@@ -41,75 +41,75 @@ reinit_slave() {
41
41
make install > /dev/null
42
42
43
43
44
- cat << MSG
45
- ###############################################################################
46
- # Check that we can commit after soft restart.
47
- # Here checkpoint happens before shutdown and no WAL replay will not occur
48
- # during start. So code should re-create memory state from files.
49
- ###############################################################################
50
- MSG
44
+ # cat <<MSG
45
+ # # ##############################################################################
46
+ # # Check that we can commit after soft restart.
47
+ # # Here checkpoint happens before shutdown and no WAL replay will not occur
48
+ # # during start. So code should re-create memory state from files.
49
+ # # ##############################################################################
50
+ # MSG
51
51
52
- pkill -9 postgres
53
- reinit_master >> /dev/null
54
- psql << SQL
55
- begin;
56
- insert into t values (42);
57
- prepare transaction 'x';
58
- SQL
59
- ./install/bin/pg_ctl -w -D ./install/data -l ./install/data/logfile restart
60
- psql << SQL
61
- commit prepared 'x';
62
- SQL
52
+ # pkill -9 postgres
53
+ # reinit_master >> /dev/null
54
+ # psql <<SQL
55
+ # begin;
56
+ # insert into t values (42);
57
+ # prepare transaction 'x';
58
+ # SQL
59
+ # ./install/bin/pg_ctl -w -D ./install/data -l ./install/data/logfile restart
60
+ # psql <<SQL
61
+ # commit prepared 'x';
62
+ # SQL
63
63
64
64
65
65
66
- cat << MSG
67
- ###############################################################################
68
- # Check that we can commit after hard restart.
69
- # On startup WAL replay will re-create memory for global transactions that
70
- # happend after last checkpoint and stored. After that
71
- ###############################################################################
72
- MSG
66
+ # cat <<MSG
67
+ # # ##############################################################################
68
+ # # Check that we can commit after hard restart.
69
+ # # On startup WAL replay will re-create memory for global transactions that
70
+ # # happend after last checkpoint and stored. After that
71
+ # # ##############################################################################
72
+ # MSG
73
73
74
- pkill -9 postgres
75
- reinit_master >> /dev/null
76
- psql << SQL
77
- begin;
78
- insert into t values (42);
79
- prepare transaction 'x';
80
- SQL
81
- pkill -9 postgres
82
- ./install/bin/pg_ctl -w -D ./install/data -l ./install/data/logfile start
83
- psql << SQL
84
- commit prepared 'x';
85
- SQL
74
+ # pkill -9 postgres
75
+ # reinit_master >> /dev/null
76
+ # psql <<SQL
77
+ # begin;
78
+ # insert into t values (42);
79
+ # prepare transaction 'x';
80
+ # SQL
81
+ # pkill -9 postgres
82
+ # ./install/bin/pg_ctl -w -D ./install/data -l ./install/data/logfile start
83
+ # psql <<SQL
84
+ # commit prepared 'x';
85
+ # SQL
86
86
87
87
88
- cat << MSG
89
- ###############################################################################
90
- # Check that WAL replay will delete memory state for commited 2pc tx.
91
- ###############################################################################
92
- MSG
88
+ # cat <<MSG
89
+ # ###############################################################################
90
+ # # Check that WAL replay will cleanup it's memory state and release locks while
91
+ # # replaying commit.
92
+ # ###############################################################################
93
+ # MSG
93
94
94
- pkill -9 postgres
95
- reinit_master >> /dev/null
96
- psql << SQL
97
- begin;
98
- insert into t values (42);
99
- prepare transaction 'x';
100
- commit prepared 'x';
101
- SQL
102
- pkill -9 postgres
103
- ./install/bin/pg_ctl -w -D ./install/data -l ./install/data/logfile start
104
- # ./install/bin/pg_ctl -w -D ./install/data -l ./install/data/logfile restart
105
- psql << SQL
106
- begin;
107
- insert into t values (42);
95
+ # pkill -9 postgres
96
+ # reinit_master >> /dev/null
97
+ # psql <<SQL
98
+ # begin;
99
+ # insert into t values (42);
100
+ # prepare transaction 'x';
101
+ # commit prepared 'x';
102
+ # SQL
103
+ # pkill -9 postgres
104
+ # ./install/bin/pg_ctl -w -D ./install/data -l ./install/data/logfile start
105
+ # psql <<SQL
106
+ # begin;
107
+ # insert into t values (42);
108
108
109
- -- This prepare can fail due to 2pc identifier conflict if replay
110
- -- didn't clean proc and gxact on commit.
111
- prepare transaction 'x';
112
- SQL
109
+ # -- This prepare can fail due to 2pc identifier or locks conflict if replay
110
+ # -- didn't clean proc, gxact and locks on commit.
111
+ # prepare transaction 'x';
112
+ # SQL
113
113
114
114
115
115
@@ -127,27 +127,140 @@ SQL
127
127
# begin;
128
128
# insert into t values (42);
129
129
# prepare transaction 'x';
130
+ # commit prepared 'x';
130
131
# SQL
132
+ # echo "Following list should be empty:"
133
+ # psql -tc 'select * from pg_prepared_xacts;' -p 5433
134
+
135
+
136
+ # cat <<MSG
137
+ # ###############################################################################
138
+ # # The same as in previous case, but let's force checkpoint on slave between
139
+ # # prepare and commit.
140
+ # ###############################################################################
141
+ # MSG
142
+
131
143
# pkill -9 postgres
132
- # ./install/bin/pg_ctl -w -D ./install/data -l ./install/data/logfile start
144
+ # reinit_master >> /dev/null
145
+ # reinit_slave >> /dev/null
146
+ # psql <<SQL
147
+ # begin;
148
+ # insert into t values (42);
149
+ # prepare transaction 'x';
150
+ # SQL
151
+ # psql -p 5433 <<SQL
152
+ # checkpoint;
153
+ # SQL
133
154
# psql <<SQL
134
155
# commit prepared 'x';
135
156
# SQL
136
157
# echo "Following list should be empty:"
137
158
# psql -tc 'select * from pg_prepared_xacts;' -p 5433
138
159
139
160
161
+ # cat <<MSG
162
+ # ###############################################################################
163
+ # # Check that we can commit transaction on promoted slave.
164
+ # ###############################################################################
165
+ # MSG
140
166
167
+ # pkill -9 postgres
168
+ # reinit_master >> /dev/null
169
+ # reinit_slave >> /dev/null
170
+ # psql <<SQL
171
+ # begin;
172
+ # insert into t values (42);
173
+ # prepare transaction 'x';
174
+ # SQL
175
+ # kill -9 `cat install/data/postmaster.pid | head -n 1`
176
+ # ./install/bin/pg_ctl promote -D ./install/data_slave
177
+ # sleep 1 # is there a clever way to wait for promotion?
178
+ # psql -p 5433 <<SQL
179
+ # commit prepared 'x';
180
+ # SQL
141
181
142
182
183
+ # cat <<MSG
184
+ # ###############################################################################
185
+ # # Check StandbyRecoverPreparedTransactions
186
+ # ###############################################################################
187
+ # MSG
143
188
189
+ # pkill -9 postgres
190
+ # reinit_master
191
+ # reinit_slave
192
+ # psql <<SQL
193
+ # begin;
194
+ # insert into t values (42);
195
+ # savepoint s1;
196
+ # insert into t values (43);
197
+ # prepare transaction 'x';
198
+ # insert into t values (100);
199
+ # SQL
200
+ # # kill -9 `cat install/data_slave/postmaster.pid | head -n 1`
201
+ # # sleep 1
202
+ # ./install/bin/pg_ctl -w -D ./install/data -l ./install/data/logfile stop
203
+ # # ./install/bin/pg_ctl -w -D ./install/data_slave -l ./install/data_slave/logfile restart
204
+ # # ./install/bin/pg_ctl -w -D ./install/data -l ./install/data/logfile start
205
+ # ./install/bin/pg_ctl promote -D ./install/data_slave
206
+ # sleep 6 # is there a clever way to wait for promotion?
207
+ # psql -p5433 <<SQL
208
+ # commit prepared 'x';
209
+ # SQL
144
210
145
211
146
212
147
213
214
+ cat << MSG
215
+ ###############################################################################
216
+ # Check that we can commit after soft restart.
217
+ # Here checkpoint happens before shutdown and no WAL replay will not occur
218
+ # during start. So code should re-create memory state from files.
219
+ ###############################################################################
220
+ MSG
221
+
222
+ pkill -9 postgres
223
+ reinit_master >> /dev/null
224
+ psql << SQL
225
+ begin;
226
+ insert into t values (42);
227
+ savepoint s1;
228
+ insert into t values (43);
229
+ prepare transaction 'x';
230
+ insert into t values (100);
231
+ SQL
232
+ ./install/bin/pg_ctl -w -D ./install/data -l ./install/data/logfile restart
233
+ psql << SQL
234
+ commit prepared 'x';
235
+ SQL
148
236
149
237
150
238
239
+ cat << MSG
240
+ ###############################################################################
241
+ # Check that we can commit after hard restart.
242
+ # On startup WAL replay will re-create memory for global transactions that
243
+ # happend after last checkpoint and stored. After that
244
+ ###############################################################################
245
+ MSG
246
+
247
+ pkill -9 postgres
248
+ reinit_master >> /dev/null
249
+ psql << SQL
250
+ begin;
251
+ insert into t values (42);
252
+ savepoint s1;
253
+ insert into t values (43);
254
+ select txid_current();
255
+ prepare transaction 'x';
256
+ SQL
257
+ pkill -9 postgres
258
+ ./install/bin/pg_ctl -w -D ./install/data -l ./install/data/logfile start
259
+ psql << SQL
260
+ select txid_current();
261
+ insert into t values (44);
262
+ commit prepared 'x';
263
+ SQL
151
264
152
265
153
266
0 commit comments