forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitc3b23ae
committed
Don't to predicate lock for analyze scans, refactor scan option passing.
Before this commit, when ANALYZE was run on a table and serializablewas used (either by virtue of an explicit BEGIN TRANSACTION ISOLATIONLEVEL SERIALIZABLE, or default_transaction_isolation being set toserializable) a null pointer dereference lead to a crash.The analyze scan doesn't need a snapshot (nor predicate locking), butbefore this commit a scan only contained information about being abitmap or sample scan.Refactor the option passing to the scan_begin callback to use abitmask instead. Alternatively we could have added a new booleanparameter, but that seems harder to read. Even before this issuevarious people (Heikki, Tom, Robert) suggested doing so.These changes don't change the scan APIs outside of tableam. The flagsargument could be exposed, it's not necessary to fix thisproblem. Also the wrapper table_beginscan* functions encapsulate mostof that complexity.After these changes fixing the bug is trivial, just don't acquirepredicate lock for analyze style scans. That was already done forbitmap heap scans. Add an assert that a snapshot is passed whenacquiring the predicate lock, so this kind of bug doesn't requirerunning with serializable.Also add a comment about sample scans currently requiring predicatelocking the entire relation, that previously wasn't remarked upon.Reported-By: Joe WildishAuthor: Andres FreundDiscussion:https://postgr.es/m/4EA80A20-E9BF-49F1-9F01-5B66CAB21453@elusive.cxhttps://postgr.es/m/20190411164947.nkii4gaeilt4bui7@alap3.anarazel.dehttps://postgr.es/m/20190518203102.g7peu2fianukjuxm@alap3.anarazel.de1 parentbd1592e commitc3b23ae
File tree
8 files changed
+160
-102
lines changed- src
- backend/access
- heap
- table
- include/access
- test/regress
- expected
- sql
8 files changed
+160
-102
lines changedLines changed: 69 additions & 51 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
245 | 245 |
| |
246 | 246 |
| |
247 | 247 |
| |
248 |
| - | |
249 |
| - | |
| 248 | + | |
| 249 | + | |
250 | 250 |
| |
251 | 251 |
| |
252 | 252 |
| |
| |||
267 | 267 |
| |
268 | 268 |
| |
269 | 269 |
| |
270 |
| - | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
271 | 274 |
| |
272 | 275 |
| |
273 | 276 |
| |
| |||
276 | 279 |
| |
277 | 280 |
| |
278 | 281 |
| |
279 |
| - | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
280 | 286 |
| |
281 | 287 |
| |
282 | 288 |
| |
283 |
| - | |
| 289 | + | |
284 | 290 |
| |
285 | 291 |
| |
286 | 292 |
| |
287 | 293 |
| |
288 |
| - | |
| 294 | + | |
289 | 295 |
| |
290 | 296 |
| |
291 | 297 |
| |
| |||
305 | 311 |
| |
306 | 312 |
| |
307 | 313 |
| |
308 |
| - | |
309 |
| - | |
310 |
| - | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
311 | 317 |
| |
312 |
| - | |
| 318 | + | |
313 | 319 |
| |
314 | 320 |
| |
315 | 321 |
| |
| |||
325 | 331 |
| |
326 | 332 |
| |
327 | 333 |
| |
328 |
| - | |
| 334 | + | |
| 335 | + | |
329 | 336 |
| |
330 | 337 |
| |
331 | 338 |
| |
| |||
375 | 382 |
| |
376 | 383 |
| |
377 | 384 |
| |
378 |
| - | |
| 385 | + | |
379 | 386 |
| |
380 | 387 |
| |
381 | 388 |
| |
| |||
574 | 581 |
| |
575 | 582 |
| |
576 | 583 |
| |
577 |
| - | |
| 584 | + | |
578 | 585 |
| |
579 | 586 |
| |
580 | 587 |
| |
| |||
738 | 745 |
| |
739 | 746 |
| |
740 | 747 |
| |
741 |
| - | |
| 748 | + | |
742 | 749 |
| |
743 | 750 |
| |
744 | 751 |
| |
| |||
885 | 892 |
| |
886 | 893 |
| |
887 | 894 |
| |
888 |
| - | |
| 895 | + | |
889 | 896 |
| |
890 | 897 |
| |
891 | 898 |
| |
| |||
1037 | 1044 |
| |
1038 | 1045 |
| |
1039 | 1046 |
| |
1040 |
| - | |
| 1047 | + | |
1041 | 1048 |
| |
1042 | 1049 |
| |
1043 | 1050 |
| |
| |||
1125 | 1132 |
| |
1126 | 1133 |
| |
1127 | 1134 |
| |
1128 |
| - | |
1129 |
| - | |
1130 |
| - | |
1131 |
| - | |
1132 |
| - | |
1133 |
| - | |
| 1135 | + | |
1134 | 1136 |
| |
1135 | 1137 |
| |
1136 | 1138 |
| |
| |||
1151 | 1153 |
| |
1152 | 1154 |
| |
1153 | 1155 |
| |
1154 |
| - | |
1155 |
| - | |
1156 |
| - | |
1157 |
| - | |
1158 |
| - | |
1159 |
| - | |
| 1156 | + | |
1160 | 1157 |
| |
| 1158 | + | |
1161 | 1159 |
| |
1162 | 1160 |
| |
1163 |
| - | |
| 1161 | + | |
1164 | 1162 |
| |
1165 |
| - | |
1166 |
| - | |
| 1163 | + | |
| 1164 | + | |
1167 | 1165 |
| |
1168 | 1166 |
| |
1169 |
| - | |
1170 |
| - | |
1171 |
| - | |
1172 |
| - | |
1173 |
| - | |
1174 |
| - | |
1175 |
| - | |
1176 |
| - | |
1177 |
| - | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
1178 | 1178 |
| |
1179 |
| - | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
1180 | 1187 |
| |
| 1188 | + | |
1181 | 1189 |
| |
1182 | 1190 |
| |
1183 | 1191 |
| |
| |||
1204 | 1212 |
| |
1205 | 1213 |
| |
1206 | 1214 |
| |
1207 |
| - | |
1208 |
| - | |
1209 |
| - | |
1210 |
| - | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
1211 | 1230 |
| |
1212 | 1231 |
| |
1213 | 1232 |
| |
| |||
1246 | 1265 |
| |
1247 | 1266 |
| |
1248 | 1267 |
| |
1249 |
| - | |
| 1268 | + | |
1250 | 1269 |
| |
1251 | 1270 |
| |
1252 | 1271 |
| |
| |||
1288 | 1307 |
| |
1289 | 1308 |
| |
1290 | 1309 |
| |
1291 |
| - | |
| 1310 | + | |
1292 | 1311 |
| |
1293 | 1312 |
| |
1294 | 1313 |
| |
| |||
1335 | 1354 |
| |
1336 | 1355 |
| |
1337 | 1356 |
| |
1338 |
| - | |
1339 |
| - | |
1340 |
| - | |
| 1357 | + | |
| 1358 | + | |
1341 | 1359 |
| |
1342 |
| - | |
| 1360 | + | |
1343 | 1361 |
| |
1344 | 1362 |
| |
1345 | 1363 |
| |
|
Lines changed: 3 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2323 | 2323 |
| |
2324 | 2324 |
| |
2325 | 2325 |
| |
2326 |
| - | |
| 2326 | + | |
2327 | 2327 |
| |
2328 | 2328 |
| |
2329 | 2329 |
| |
| |||
2357 | 2357 |
| |
2358 | 2358 |
| |
2359 | 2359 |
| |
2360 |
| - | |
| 2360 | + | |
2361 | 2361 |
| |
2362 | 2362 |
| |
2363 | 2363 |
| |
| |||
2504 | 2504 |
| |
2505 | 2505 |
| |
2506 | 2506 |
| |
2507 |
| - | |
| 2507 | + | |
2508 | 2508 |
| |
2509 | 2509 |
| |
2510 | 2510 |
| |
|
Lines changed: 8 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
93 | 93 |
| |
94 | 94 |
| |
95 | 95 |
| |
| 96 | + | |
| 97 | + | |
96 | 98 |
| |
97 | 99 |
| |
98 | 100 |
| |
99 | 101 |
| |
100 |
| - | |
101 |
| - | |
| 102 | + | |
102 | 103 |
| |
103 | 104 |
| |
104 | 105 |
| |
| |||
108 | 109 |
| |
109 | 110 |
| |
110 | 111 |
| |
111 |
| - | |
| 112 | + | |
112 | 113 |
| |
113 | 114 |
| |
114 | 115 |
| |
| |||
156 | 157 |
| |
157 | 158 |
| |
158 | 159 |
| |
| 160 | + | |
| 161 | + | |
159 | 162 |
| |
160 | 163 |
| |
161 | 164 |
| |
| |||
165 | 168 |
| |
166 | 169 |
| |
167 | 170 |
| |
| 171 | + | |
168 | 172 |
| |
169 | 173 |
| |
170 | 174 |
| |
| |||
173 | 177 |
| |
174 | 178 |
| |
175 | 179 |
| |
176 |
| - | |
177 |
| - | |
178 |
| - | |
| 180 | + | |
179 | 181 |
| |
180 | 182 |
| |
181 | 183 |
| |
|
Lines changed: 1 addition & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
110 | 110 |
| |
111 | 111 |
| |
112 | 112 |
| |
113 |
| - | |
114 |
| - | |
115 |
| - | |
116 |
| - | |
117 |
| - | |
118 |
| - | |
| 113 | + | |
119 | 114 |
| |
120 | 115 |
| |
121 | 116 |
| |
|
Lines changed: 6 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
35 | 35 |
| |
36 | 36 |
| |
37 | 37 |
| |
38 |
| - | |
39 |
| - | |
40 |
| - | |
41 |
| - | |
42 |
| - | |
43 |
| - | |
44 |
| - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
45 | 44 |
| |
46 | 45 |
| |
47 | 46 |
| |
|
0 commit comments
Comments
(0)