- Notifications
You must be signed in to change notification settings - Fork4.9k
Commit81ee435
committed
Fix subtransaction cleanup after an outer-subtransaction portal fails.
Formerly, we treated only portals created in the current subtransaction ashaving failed during subtransaction abort. However, if the error occurredwhile running a portal created in an outer subtransaction (ie, a cursordeclared before the last savepoint), that has to be considered broken too.To allow reliable detection of which ones those are, add a bookkeepingfield to struct Portal that tracks the innermost subtransaction in whicheach portal has actually been executed. (Without this, we'd end upfailing portals containing functions that had called the subtransaction,thereby breaking plpgsql exception blocks completely.)In addition, when we fail an outer-subtransaction Portal, transfer itsresources into the subtransaction's resource owner, so that they'rereleased early in cleanup of the subxact. This fixes a problem reported byJim Nasby in which a function executed in an outer-subtransaction cursorcould cause an Assert failure or crash by referencing a relation createdwithin the inner subtransaction.The proximate cause of the Assert failure is that AtEOSubXact_RelationCacheassumed it could blow away a relcache entry without first checking that theentry had zero refcount. That was a bad idea on its own terms, so add sucha check there, and to the similar coding in AtEOXact_RelationCache. Thisprovides an independent safety measure in case there are still ways toprovoke the situation despite the Portal-level changes.This has been broken since subtransactions were invented, so back-patchto all supported branches.Tom Lane and Michael Paquier1 parentb5a22d8 commit81ee435
File tree
8 files changed
+192
-14
lines changed- src
- backend
- access/transam
- commands
- tcop
- utils
- cache
- mmgr
- include/utils
- test/regress
- expected
- sql
8 files changed
+192
-14
lines changedLines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
4101 | 4101 |
| |
4102 | 4102 |
| |
4103 | 4103 |
| |
| 4104 | + | |
4104 | 4105 |
| |
4105 | 4106 |
| |
4106 | 4107 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
329 | 329 |
| |
330 | 330 |
| |
331 | 331 |
| |
| 332 | + | |
332 | 333 |
| |
333 | 334 |
| |
334 | 335 |
| |
|
Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
748 | 748 |
| |
749 | 749 |
| |
750 | 750 |
| |
| 751 | + | |
751 | 752 |
| |
752 | 753 |
| |
753 | 754 |
| |
| |||
1372 | 1373 |
| |
1373 | 1374 |
| |
1374 | 1375 |
| |
| 1376 | + | |
1375 | 1377 |
| |
1376 | 1378 |
| |
1377 | 1379 |
| |
|
Lines changed: 33 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1855 | 1855 |
| |
1856 | 1856 |
| |
1857 | 1857 |
| |
1858 |
| - | |
| 1858 | + | |
| 1859 | + | |
| 1860 | + | |
1859 | 1861 |
| |
1860 | 1862 |
| |
1861 | 1863 |
| |
| |||
2345 | 2347 |
| |
2346 | 2348 |
| |
2347 | 2349 |
| |
2348 |
| - | |
| 2350 | + | |
2349 | 2351 |
| |
2350 | 2352 |
| |
2351 | 2353 |
| |
2352 | 2354 |
| |
| 2355 | + | |
| 2356 | + | |
| 2357 | + | |
| 2358 | + | |
| 2359 | + | |
| 2360 | + | |
| 2361 | + | |
| 2362 | + | |
| 2363 | + | |
| 2364 | + | |
| 2365 | + | |
| 2366 | + | |
| 2367 | + | |
| 2368 | + | |
2353 | 2369 |
| |
2354 | 2370 |
| |
2355 | 2371 |
| |
| |||
2410 | 2426 |
| |
2411 | 2427 |
| |
2412 | 2428 |
| |
2413 |
| - | |
| 2429 | + | |
2414 | 2430 |
| |
2415 | 2431 |
| |
2416 | 2432 |
| |
2417 | 2433 |
| |
| 2434 | + | |
| 2435 | + | |
| 2436 | + | |
| 2437 | + | |
| 2438 | + | |
| 2439 | + | |
| 2440 | + | |
| 2441 | + | |
| 2442 | + | |
| 2443 | + | |
| 2444 | + | |
| 2445 | + | |
| 2446 | + | |
| 2447 | + | |
2418 | 2448 |
| |
2419 | 2449 |
| |
2420 | 2450 |
| |
|
Lines changed: 63 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
231 | 231 |
| |
232 | 232 |
| |
233 | 233 |
| |
| 234 | + | |
234 | 235 |
| |
235 | 236 |
| |
236 | 237 |
| |
| |||
581 | 582 |
| |
582 | 583 |
| |
583 | 584 |
| |
| 585 | + | |
584 | 586 |
| |
585 | 587 |
| |
586 | 588 |
| |
| |||
793 | 795 |
| |
794 | 796 |
| |
795 | 797 |
| |
796 |
| - | |
797 |
| - | |
| 798 | + | |
| 799 | + | |
798 | 800 |
| |
799 | 801 |
| |
800 | 802 |
| |
| |||
816 | 818 |
| |
817 | 819 |
| |
818 | 820 |
| |
| 821 | + | |
| 822 | + | |
819 | 823 |
| |
820 | 824 |
| |
821 | 825 |
| |
822 | 826 |
| |
823 | 827 |
| |
824 | 828 |
| |
825 |
| - | |
826 |
| - | |
| 829 | + | |
| 830 | + | |
827 | 831 |
| |
828 | 832 |
| |
829 | 833 |
| |
830 | 834 |
| |
831 | 835 |
| |
832 | 836 |
| |
833 | 837 |
| |
| 838 | + | |
834 | 839 |
| |
835 | 840 |
| |
836 | 841 |
| |
| |||
842 | 847 |
| |
843 | 848 |
| |
844 | 849 |
| |
| 850 | + | |
845 | 851 |
| |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
846 | 902 |
| |
| 903 | + | |
847 | 904 |
| |
848 | 905 |
| |
849 | 906 |
| |
850 | 907 |
| |
851 |
| - | |
852 |
| - | |
853 |
| - | |
854 |
| - | |
| 908 | + | |
| 909 | + | |
855 | 910 |
| |
856 | 911 |
| |
857 | 912 |
| |
|
Lines changed: 14 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
112 | 112 |
| |
113 | 113 |
| |
114 | 114 |
| |
115 |
| - | |
116 | 115 |
| |
117 | 116 |
| |
118 |
| - | |
119 |
| - | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
120 | 122 |
| |
| 123 | + | |
121 | 124 |
| |
122 | 125 |
| |
123 | 126 |
| |
| |||
168 | 171 |
| |
169 | 172 |
| |
170 | 173 |
| |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
171 | 181 |
| |
172 | 182 |
| |
173 | 183 |
| |
| |||
196 | 206 |
| |
197 | 207 |
| |
198 | 208 |
| |
| 209 | + | |
199 | 210 |
| |
200 | 211 |
| |
201 | 212 |
| |
|
Lines changed: 46 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
527 | 527 |
| |
528 | 528 |
| |
529 | 529 |
| |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
530 | 576 |
| |
531 | 577 |
| |
532 | 578 |
| |
|
Lines changed: 32 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
326 | 326 |
| |
327 | 327 |
| |
328 | 328 |
| |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
329 | 361 |
| |
330 | 362 |
| |
331 | 363 |
| |
|
0 commit comments
Comments
(0)