forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitf868a81
committed
Fix longstanding recursion hazard in sinval message processing.
LockRelationOid and sibling routines supposed that, if our session alreadyholds the lock they were asked to acquire, they could skip callingAcceptInvalidationMessages on the grounds that we must have already readany remote sinval messages issued against the relation being locked.This is normally true, but there's a critical special case where it's not:processing inside AcceptInvalidationMessages might attempt to access systemrelations, resulting in a recursive call to acquire a relation lock.Hence, if the outer call had acquired that same system catalog lock, we'dfall through, despite the possibility that there's an as-yet-unread sinvalmessage for that system catalog. This could, for example, result infailure to access a system catalog or index that had just been processedby VACUUM FULL. This is the explanation for buildfarm failures we've beenseeing intermittently for the past three months. The bug is far olderthan that, but commitsa54e1f1 et al added a new recursion case withinAcceptInvalidationMessages that is apparently easier to hit than anyprevious case.To fix this, we must not skip calling AcceptInvalidationMessages untilwe have *finished* a call to it since acquiring a relation lock, notmerely acquired the lock. (There's already adequate logic insideAcceptInvalidationMessages to deal with being called recursively.)Fortunately, we can implement that at trivial cost, by adding a flagto LOCALLOCK hashtable entries that tracks whether we know we havecompleted such a call.There is an API hazard added by this patch for external callers ofLockAcquire: if anything is testing for LOCKACQUIRE_ALREADY_HELD,it might be fooled by the new return code LOCKACQUIRE_ALREADY_CLEARinto thinking the lock wasn't already held. This should be a fail-softcondition, though, unless something very bizarre is being done inresponse to the test.Also, I added an additional output argument to LockAcquireExtended,assuming that that probably isn't called by any outside code giventhe very limited usefulness of its additional functionality.Back-patch to all supported branches.Discussion:https://postgr.es/m/12259.1532117714@sss.pgh.pa.us1 parent8582b4d commitf868a81
4 files changed
+92
-16
lines changedLines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
661 | 661 |
| |
662 | 662 |
| |
663 | 663 |
| |
664 |
| - | |
| 664 | + | |
| 665 | + | |
665 | 666 |
| |
666 | 667 |
| |
667 | 668 |
| |
|
Lines changed: 30 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
105 | 105 |
| |
106 | 106 |
| |
107 | 107 |
| |
| 108 | + | |
108 | 109 |
| |
109 | 110 |
| |
110 | 111 |
| |
111 | 112 |
| |
112 |
| - | |
| 113 | + | |
113 | 114 |
| |
114 | 115 |
| |
115 | 116 |
| |
| |||
120 | 121 |
| |
121 | 122 |
| |
122 | 123 |
| |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
123 | 130 |
| |
124 |
| - | |
| 131 | + | |
| 132 | + | |
125 | 133 |
| |
| 134 | + | |
| 135 | + | |
126 | 136 |
| |
127 | 137 |
| |
128 | 138 |
| |
| |||
138 | 148 |
| |
139 | 149 |
| |
140 | 150 |
| |
| 151 | + | |
141 | 152 |
| |
142 | 153 |
| |
143 | 154 |
| |
144 | 155 |
| |
145 |
| - | |
| 156 | + | |
146 | 157 |
| |
147 | 158 |
| |
148 | 159 |
| |
| |||
151 | 162 |
| |
152 | 163 |
| |
153 | 164 |
| |
154 |
| - | |
| 165 | + | |
| 166 | + | |
155 | 167 |
| |
| 168 | + | |
| 169 | + | |
156 | 170 |
| |
157 | 171 |
| |
158 | 172 |
| |
| |||
199 | 213 |
| |
200 | 214 |
| |
201 | 215 |
| |
| 216 | + | |
202 | 217 |
| |
203 | 218 |
| |
204 | 219 |
| |
205 | 220 |
| |
206 | 221 |
| |
207 | 222 |
| |
208 |
| - | |
| 223 | + | |
209 | 224 |
| |
210 | 225 |
| |
211 | 226 |
| |
212 | 227 |
| |
213 | 228 |
| |
214 |
| - | |
| 229 | + | |
| 230 | + | |
215 | 231 |
| |
| 232 | + | |
| 233 | + | |
216 | 234 |
| |
217 | 235 |
| |
218 | 236 |
| |
| |||
226 | 244 |
| |
227 | 245 |
| |
228 | 246 |
| |
| 247 | + | |
229 | 248 |
| |
230 | 249 |
| |
231 | 250 |
| |
232 | 251 |
| |
233 | 252 |
| |
234 | 253 |
| |
235 |
| - | |
| 254 | + | |
236 | 255 |
| |
237 | 256 |
| |
238 | 257 |
| |
| |||
241 | 260 |
| |
242 | 261 |
| |
243 | 262 |
| |
244 |
| - | |
| 263 | + | |
| 264 | + | |
245 | 265 |
| |
| 266 | + | |
| 267 | + | |
246 | 268 |
| |
247 | 269 |
| |
248 | 270 |
| |
|
Lines changed: 53 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
669 | 669 |
| |
670 | 670 |
| |
671 | 671 |
| |
| 672 | + | |
672 | 673 |
| |
673 | 674 |
| |
674 | 675 |
| |
| |||
685 | 686 |
| |
686 | 687 |
| |
687 | 688 |
| |
688 |
| - | |
| 689 | + | |
| 690 | + | |
689 | 691 |
| |
690 | 692 |
| |
691 | 693 |
| |
| |||
696 | 698 |
| |
697 | 699 |
| |
698 | 700 |
| |
| 701 | + | |
| 702 | + | |
| 703 | + | |
699 | 704 |
| |
700 | 705 |
| |
701 | 706 |
| |
702 | 707 |
| |
703 | 708 |
| |
704 | 709 |
| |
705 |
| - | |
| 710 | + | |
| 711 | + | |
706 | 712 |
| |
707 | 713 |
| |
708 | 714 |
| |
| |||
766 | 772 |
| |
767 | 773 |
| |
768 | 774 |
| |
| 775 | + | |
| 776 | + | |
769 | 777 |
| |
770 | 778 |
| |
771 |
| - | |
772 | 779 |
| |
773 | 780 |
| |
774 | 781 |
| |
| |||
789 | 796 |
| |
790 | 797 |
| |
791 | 798 |
| |
| 799 | + | |
| 800 | + | |
| 801 | + | |
792 | 802 |
| |
793 | 803 |
| |
| 804 | + | |
| 805 | + | |
| 806 | + | |
794 | 807 |
| |
795 | 808 |
| |
796 | 809 |
| |
797 | 810 |
| |
798 |
| - | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
799 | 815 |
| |
800 | 816 |
| |
801 | 817 |
| |
| |||
877 | 893 |
| |
878 | 894 |
| |
879 | 895 |
| |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
880 | 900 |
| |
881 | 901 |
| |
882 | 902 |
| |
| |||
911 | 931 |
| |
912 | 932 |
| |
913 | 933 |
| |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
914 | 938 |
| |
915 | 939 |
| |
916 | 940 |
| |
| |||
976 | 1000 |
| |
977 | 1001 |
| |
978 | 1002 |
| |
| 1003 | + | |
| 1004 | + | |
979 | 1005 |
| |
980 | 1006 |
| |
981 | 1007 |
| |
| |||
1645 | 1671 |
| |
1646 | 1672 |
| |
1647 | 1673 |
| |
| 1674 | + | |
| 1675 | + | |
| 1676 | + | |
| 1677 | + | |
| 1678 | + | |
| 1679 | + | |
| 1680 | + | |
| 1681 | + | |
| 1682 | + | |
| 1683 | + | |
| 1684 | + | |
| 1685 | + | |
| 1686 | + | |
| 1687 | + | |
1648 | 1688 |
| |
1649 | 1689 |
| |
1650 | 1690 |
| |
| |||
1909 | 1949 |
| |
1910 | 1950 |
| |
1911 | 1951 |
| |
| 1952 | + | |
| 1953 | + | |
| 1954 | + | |
| 1955 | + | |
| 1956 | + | |
| 1957 | + | |
| 1958 | + | |
| 1959 | + | |
| 1960 | + | |
1912 | 1961 |
| |
1913 | 1962 |
| |
1914 | 1963 |
| |
|
Lines changed: 7 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
408 | 408 |
| |
409 | 409 |
| |
410 | 410 |
| |
| 411 | + | |
| 412 | + | |
411 | 413 |
| |
412 | 414 |
| |
413 |
| - | |
414 | 415 |
| |
415 | 416 |
| |
416 | 417 |
| |
| |||
472 | 473 |
| |
473 | 474 |
| |
474 | 475 |
| |
475 |
| - | |
| 476 | + | |
| 477 | + | |
476 | 478 |
| |
477 | 479 |
| |
478 | 480 |
| |
| |||
528 | 530 |
| |
529 | 531 |
| |
530 | 532 |
| |
531 |
| - | |
| 533 | + | |
| 534 | + | |
532 | 535 |
| |
| 536 | + | |
533 | 537 |
| |
534 | 538 |
| |
535 | 539 |
| |
|
0 commit comments
Comments
(0)