- Notifications
You must be signed in to change notification settings - Fork4.9k
Commit19de0ab
committed
Fix inadequate locking during get_rel_oids().
get_rel_oids used to not take any relation locks at all, but that stoppedbeing a good idea with commit3c3bb99, which inserted a syscache lookupinto the function. A concurrent DROP TABLE could now produce "cache lookupfailed", which we don't want to have happen in normal operation. The bestsolution seems to be to transiently take a lock on the relation named bythe RangeVar (which also makes the result of RangeVarGetRelid a lot lessspongy). But we shouldn't hold the lock beyond this function, because wedon't want VACUUM to lock more than one table at a time. (That would notbe a big problem right now, but it will become one after the pendingfeature patch to allow multiple tables to be named in VACUUM.)In passing, adjust vacuum_rel and analyze_rel to document that we don'ttrust the passed RangeVar to be accurate, and allow the RangeVar topossibly be NULL --- which it is anyway for a whole-database VACUUM,though we accidentally didn't crash for that case.The passed RangeVar is in fact inaccurate when dealing with a childpartition, as of v10, and it has been wrong for a whole long time in thecase of vacuum_rel() recursing to a TOAST table. None of these thingspresent visible bugs up to now, because the passed RangeVar is in factonly consulted for autovacuum logging, and in that particular context it'salways accurate because autovacuum doesn't let vacuum.c expand partitionsnor recurse to toast tables. Still, this seems like trouble waiting tohappen, so let's nail the door at least partly shut. (Further cleanupis planned, in HEAD only, as part of the pending feature patch.)Fix some sadly inaccurate/obsolete comments too. Back-patch to v10.Michael Paquier and Tom LaneDiscussion:https://postgr.es/m/25023.1506107590@sss.pgh.pa.us1 parent69c1698 commit19de0ab
2 files changed
+45
-22
lines changedLines changed: 6 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
106 | 106 |
| |
107 | 107 |
| |
108 | 108 |
| |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
109 | 113 |
| |
110 | 114 |
| |
111 | 115 |
| |
| |||
145 | 149 |
| |
146 | 150 |
| |
147 | 151 |
| |
148 |
| - | |
| 152 | + | |
| 153 | + | |
149 | 154 |
| |
150 | 155 |
| |
151 | 156 |
| |
|
Lines changed: 39 additions & 21 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
128 | 128 |
| |
129 | 129 |
| |
130 | 130 |
| |
131 |
| - | |
132 |
| - | |
133 |
| - | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
134 | 136 |
| |
135 | 137 |
| |
136 | 138 |
| |
| |||
226 | 228 |
| |
227 | 229 |
| |
228 | 230 |
| |
229 |
| - | |
230 |
| - | |
| 231 | + | |
| 232 | + | |
231 | 233 |
| |
232 | 234 |
| |
233 | 235 |
| |
| |||
393 | 395 |
| |
394 | 396 |
| |
395 | 397 |
| |
396 |
| - | |
| 398 | + | |
397 | 399 |
| |
398 | 400 |
| |
399 | 401 |
| |
400 | 402 |
| |
401 | 403 |
| |
402 | 404 |
| |
403 |
| - | |
404 |
| - | |
405 |
| - | |
406 |
| - | |
407 |
| - | |
408 |
| - | |
409 |
| - | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
410 | 408 |
| |
411 |
| - | |
| 409 | + | |
412 | 410 |
| |
413 | 411 |
| |
414 | 412 |
| |
| |||
422 | 420 |
| |
423 | 421 |
| |
424 | 422 |
| |
425 |
| - | |
426 |
| - | |
427 |
| - | |
428 |
| - | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
429 | 428 |
| |
430 | 429 |
| |
431 | 430 |
| |
| |||
434 | 433 |
| |
435 | 434 |
| |
436 | 435 |
| |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
437 | 449 |
| |
438 | 450 |
| |
439 | 451 |
| |
| |||
463 | 475 |
| |
464 | 476 |
| |
465 | 477 |
| |
466 |
| - | |
| 478 | + | |
467 | 479 |
| |
468 | 480 |
| |
469 | 481 |
| |
| |||
1212 | 1224 |
| |
1213 | 1225 |
| |
1214 | 1226 |
| |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
1215 | 1232 |
| |
1216 | 1233 |
| |
1217 | 1234 |
| |
| |||
1300 | 1317 |
| |
1301 | 1318 |
| |
1302 | 1319 |
| |
1303 |
| - | |
| 1320 | + | |
| 1321 | + | |
1304 | 1322 |
| |
1305 | 1323 |
| |
1306 | 1324 |
| |
| |||
1468 | 1486 |
| |
1469 | 1487 |
| |
1470 | 1488 |
| |
1471 |
| - | |
| 1489 | + | |
1472 | 1490 |
| |
1473 | 1491 |
| |
1474 | 1492 |
| |
|
0 commit comments
Comments
(0)