forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitaad0926
committed
Avoid touching replica identity index in ExtractReplicaIdentity().
In what seems like a fit of misplaced optimization,ExtractReplicaIdentity() accessed the relation's replica-identityindex without taking any lock on it. Usually, the surrounding queryalready holds some lock so this is safe enough ... but in the caseof a previously-planned delete, there might be no existing lock.Given a suitable test case, this is exposed in v12 and HEAD by anassertion added by commitb04aeb0.The whole thing's rather poorly thought out anyway; rather thanlooking directly at the index, we should use the index-attributesbitmap that's held by the parent table's relcache entry, as thecaller functions do. This is more consistent and likely a bitfaster, since it avoids a cache lookup. Hence, change to doing itthat way.While at it, rather than blithely assuming that the identitycolumns are non-null (with catastrophic results if that's wrong),add assertion checks that they aren't null. Possibly those shouldbe actual test-and-elog, but I'll leave it like this for now.In principle, this is a bug that's been there since this code wasintroduced (in 9.4). In practice, the risk seems quite low, sincewe do have a lock on the index's parent table, so concurrentchanges to the index's catalog entries seem unlikely. Given theprecedent that commit9c703c1 wasn't back-patched, I won't riskback-patching this further than v12.Per report from Hadi Moshayedi.Discussion:https://postgr.es/m/CAK=1=Wrek44Ese1V7LjKiQS-Nd-5LgLi_5_CskGbpggKEf3tKQ@mail.gmail.com1 parent90433c3 commitaad0926
1 file changed
+37
-34
lines changedLines changed: 37 additions & 34 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
7593 | 7593 |
| |
7594 | 7594 |
| |
7595 | 7595 |
| |
7596 |
| - | |
| 7596 | + | |
| 7597 | + | |
| 7598 | + | |
| 7599 | + | |
| 7600 | + | |
| 7601 | + | |
| 7602 | + | |
7597 | 7603 |
| |
7598 | 7604 |
| |
7599 |
| - | |
| 7605 | + | |
| 7606 | + | |
7600 | 7607 |
| |
7601 | 7608 |
| |
7602 |
| - | |
7603 |
| - | |
7604 | 7609 |
| |
7605 |
| - | |
| 7610 | + | |
| 7611 | + | |
7606 | 7612 |
| |
7607 | 7613 |
| |
7608 |
| - | |
7609 | 7614 |
| |
7610 | 7615 |
| |
7611 | 7616 |
| |
| |||
7624 | 7629 |
| |
7625 | 7630 |
| |
7626 | 7631 |
| |
7627 |
| - | |
| 7632 | + | |
7628 | 7633 |
| |
7629 | 7634 |
| |
7630 | 7635 |
| |
| |||
7633 | 7638 |
| |
7634 | 7639 |
| |
7635 | 7640 |
| |
7636 |
| - | |
7637 |
| - | |
7638 |
| - | |
7639 |
| - | |
7640 |
| - | |
7641 |
| - | |
7642 |
| - | |
7643 |
| - | |
7644 |
| - | |
7645 |
| - | |
7646 |
| - | |
7647 |
| - | |
7648 |
| - | |
7649 |
| - | |
7650 |
| - | |
| 7641 | + | |
| 7642 | + | |
| 7643 | + | |
7651 | 7644 |
| |
7652 |
| - | |
7653 |
| - | |
| 7645 | + | |
| 7646 | + | |
| 7647 | + | |
| 7648 | + | |
| 7649 | + | |
| 7650 | + | |
| 7651 | + | |
| 7652 | + | |
7654 | 7653 |
| |
7655 | 7654 |
| |
7656 |
| - | |
7657 |
| - | |
| 7655 | + | |
| 7656 | + | |
| 7657 | + | |
7658 | 7658 |
| |
7659 |
| - | |
7660 |
| - | |
7661 |
| - | |
| 7659 | + | |
7662 | 7660 |
| |
7663 |
| - | |
7664 |
| - | |
7665 |
| - | |
| 7661 | + | |
| 7662 | + | |
| 7663 | + | |
| 7664 | + | |
| 7665 | + | |
| 7666 | + | |
| 7667 | + | |
7666 | 7668 |
| |
7667 | 7669 |
| |
7668 | 7670 |
| |
7669 | 7671 |
| |
7670 |
| - | |
| 7672 | + | |
| 7673 | + | |
7671 | 7674 |
| |
7672 | 7675 |
| |
7673 | 7676 |
| |
| |||
7680 | 7683 |
| |
7681 | 7684 |
| |
7682 | 7685 |
| |
7683 |
| - | |
| 7686 | + | |
7684 | 7687 |
| |
7685 | 7688 |
| |
7686 | 7689 |
| |
|
0 commit comments
Comments
(0)