forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit5f12bc9
committed
Avoid improbable PANIC during heap_update.
heap_update needs to clear any existing "all visible" flag onthe old tuple's page (and on the new page too, if different).Per coding rules, to do this it must acquire pin on the appropriatevisibility-map page while not holding exclusive buffer lock;which creates a race condition since someone else could set theflag whenever we're not holding the buffer lock. The code issupposed to handle that by re-checking the flag after acquiringbuffer lock and retrying if it became set. However, one codepath through heap_update itself, as well as one in its subroutineRelationGetBufferForTuple, failed to do this. The end result,in the unlikely event that a concurrent VACUUM did set the flagwhile we're transiently not holding lock, is a non-recurring"PANIC: wrong buffer passed to visibilitymap_clear" failure.This has been seen a few times in the buildfarm since recent VACUUMchanges that added code paths that could set the all-visible flagwhile holding only exclusive buffer lock. Previously, the flagwas (usually?) set only after doing LockBufferForCleanup, whichwould insist on buffer pin count zero, thus preventing the flagfrom becoming set partway through heap_update. However, it'sclear that it's heap_update not VACUUM that's at fault here.What's less clear is whether there is any hazard from these bugsin released branches. heap_update is certainly violating APIexpectations, but if there is no code path that can set all-visiblewithout a cleanup lock then it's only a latent bug. That's not100% certain though, besides which we should worry about extensionsor future back-patch fixes that could introduce such code paths.I chose to back-patch to v12. Fixing RelationGetBufferForTuplebefore that would require also back-patching portions of olderfixes (notably0d1fe9f), which is more code churn than seemsprudent to fix a hypothetical issue.Discussion:https://postgr.es/m/2247102.1618008027@sss.pgh.pa.us1 parent4749c7f commit5f12bc9
2 files changed
+45
-23
lines changedLines changed: 27 additions & 17 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3476 | 3476 |
| |
3477 | 3477 |
| |
3478 | 3478 |
| |
3479 |
| - | |
| 3479 | + | |
3480 | 3480 |
| |
3481 | 3481 |
| |
3482 | 3482 |
| |
| |||
3538 | 3538 |
| |
3539 | 3539 |
| |
3540 | 3540 |
| |
| 3541 | + | |
| 3542 | + | |
| 3543 | + | |
| 3544 | + | |
| 3545 | + | |
| 3546 | + | |
3541 | 3547 |
| |
3542 |
| - | |
3543 |
| - | |
3544 |
| - | |
3545 |
| - | |
3546 |
| - | |
3547 |
| - | |
3548 |
| - | |
3549 |
| - | |
| 3548 | + | |
3550 | 3549 |
| |
| 3550 | + | |
| 3551 | + | |
| 3552 | + | |
| 3553 | + | |
| 3554 | + | |
| 3555 | + | |
| 3556 | + | |
| 3557 | + | |
| 3558 | + | |
| 3559 | + | |
| 3560 | + | |
| 3561 | + | |
3551 | 3562 |
| |
3552 | 3563 |
| |
3553 | 3564 |
| |
3554 | 3565 |
| |
3555 |
| - | |
| 3566 | + | |
| 3567 | + | |
3556 | 3568 |
| |
3557 | 3569 |
| |
3558 |
| - | |
3559 |
| - | |
3560 |
| - | |
| 3570 | + | |
| 3571 | + | |
| 3572 | + | |
3561 | 3573 |
| |
3562 | 3574 |
| |
3563 |
| - | |
3564 |
| - | |
3565 |
| - | |
3566 | 3575 |
| |
3567 | 3576 |
| |
3568 | 3577 |
| |
3569 |
| - | |
| 3578 | + | |
3570 | 3579 |
| |
| 3580 | + | |
3571 | 3581 |
| |
3572 | 3582 |
| |
3573 | 3583 |
| |
|
Lines changed: 18 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
284 | 284 |
| |
285 | 285 |
| |
286 | 286 |
| |
287 |
| - | |
288 |
| - | |
289 |
| - | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
290 | 294 |
| |
291 | 295 |
| |
292 | 296 |
| |
| |||
631 | 635 |
| |
632 | 636 |
| |
633 | 637 |
| |
| 638 | + | |
| 639 | + | |
634 | 640 |
| |
635 | 641 |
| |
636 | 642 |
| |
| |||
639 | 645 |
| |
640 | 646 |
| |
641 | 647 |
| |
642 |
| - | |
643 |
| - | |
644 |
| - | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
645 | 653 |
| |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
646 | 658 |
| |
647 | 659 |
| |
648 | 660 |
| |
|
0 commit comments
Comments
(0)