forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit8f3c577
committed
Fix bogus concurrent use of _hash_getnewbuf() in bucket split code.
_hash_splitbucket() obtained the base page of the new bucket by calling_hash_getnewbuf(), but it held no exclusive lock that would prevent someother process from calling _hash_getnewbuf() at the same time. This iscontrary to _hash_getnewbuf()'s API spec and could in fact cause failures.In practice, we must only call that function while holding write lock onthe hash index's metapage.An additional problem was that we'd already modified the metapage's bucketmapping data, meaning that failure to extend the index would leave us witha corrupt index.Fix both issues by moving the _hash_getnewbuf() call to just before wemodify the metapage in _hash_expandtable().Unfortunately there's still a large problem here, which is that we couldalso incur ENOSPC while trying to get an overflow page for the new bucket.That would leave the index corrupt in a more subtle way, namely that someindex tuples that should be in the new bucket might still be in the oldone. Fixing that seems substantially more difficult; even preallocating asmany pages as we could possibly need wouldn't entirely guarantee that thebucket split would complete successfully. So for today let's just dealwith the base case.Per report from Antonin Houska. Back-patch to all active branches.1 parent152c946 commit8f3c577
1 file changed
+26
-4
lines changedLines changed: 26 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
40 | 40 |
| |
41 | 41 |
| |
42 | 42 |
| |
| 43 | + | |
43 | 44 |
| |
44 | 45 |
| |
45 | 46 |
| |
| |||
179 | 180 |
| |
180 | 181 |
| |
181 | 182 |
| |
182 |
| - | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
183 | 186 |
| |
184 | 187 |
| |
185 | 188 |
| |
| |||
506 | 509 |
| |
507 | 510 |
| |
508 | 511 |
| |
| 512 | + | |
509 | 513 |
| |
510 | 514 |
| |
511 | 515 |
| |
| |||
618 | 622 |
| |
619 | 623 |
| |
620 | 624 |
| |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
621 | 632 |
| |
622 | 633 |
| |
623 | 634 |
| |
| |||
671 | 682 |
| |
672 | 683 |
| |
673 | 684 |
| |
674 |
| - | |
| 685 | + | |
| 686 | + | |
675 | 687 |
| |
676 | 688 |
| |
677 | 689 |
| |
| |||
754 | 766 |
| |
755 | 767 |
| |
756 | 768 |
| |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
757 | 774 |
| |
758 | 775 |
| |
759 | 776 |
| |
760 | 777 |
| |
| 778 | + | |
761 | 779 |
| |
762 | 780 |
| |
763 | 781 |
| |
| |||
769 | 787 |
| |
770 | 788 |
| |
771 | 789 |
| |
772 |
| - | |
773 | 790 |
| |
774 | 791 |
| |
775 | 792 |
| |
| |||
786 | 803 |
| |
787 | 804 |
| |
788 | 805 |
| |
789 |
| - | |
| 806 | + | |
790 | 807 |
| |
791 | 808 |
| |
792 | 809 |
| |
| |||
835 | 852 |
| |
836 | 853 |
| |
837 | 854 |
| |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
838 | 860 |
| |
839 | 861 |
| |
840 | 862 |
| |
|
0 commit comments
Comments
(0)