forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit216f9c1
committed
Fix tupdesc lifespan bug with AfterTriggersTableData.storeslot.
Commit25936fd adjusted things so that the "storeslot" we usefor remapping trigger tuples would have adequate lifespan, but itneglected to consider the lifespan of the tuple descriptor thatthe slot depends on. It turns out that in at least some cases, thetupdesc we are passing is a refcounted tupdesc, and the refcount forthe slot's reference can get assigned to a resource owner havingdifferent lifespan than the slot does. That leads to an error like"tupdesc reference 0x7fdef236a1b8 is not owned by resource ownerSubTransaction". Worse, because of a second oversight in the samecommit, we'd try to free the same tupdesc refcount again whilecleaning up after that error, leading to recursive errors and an"ERRORDATA_STACK_SIZE exceeded" PANIC.To fix the initial problem, let's just make a non-refcounted copyof the tupdesc we're supposed to use. That seems likely to guardagainst additional problems, since there's no strong reason forthis code to assume that what it's given is a refcounted tupdesc;in which case there's an independent hazard of the tupdesc havingshorter lifespan than the slot does. (I didn't bother trying tofree said copy, since it should go away anyway when the (sub)transaction context is cleaned up.)The other issue can be fixed by making the code added toAfterTriggerFreeQuery work like the rest of that function, ie besure that it doesn't try to free the same slot twice in the eventof recursive error cleanup.While here, also clean up minor stylistic issues in the test caseadded by25936fd: don't use "create or replace function", as anyname collision within the tests is likely to have ill effectsthat that won't mask; and don't use function names as generic astrigger_function1, especially if you're not going to drop themat the end of the test stanza.Per bug #17607 from Thomas Mc Kay. Back-patch to v12, as theprevious fix was.Discussion:https://postgr.es/m/17607-bd8ccc81226f7f80@postgresql.org1 parent1d2fec9 commit216f9c1
File tree
3 files changed
+82
-16
lines changed- src
- backend/commands
- test/regress
- expected
- sql
3 files changed
+82
-16
lines changedLines changed: 11 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
4775 | 4775 |
| |
4776 | 4776 |
| |
4777 | 4777 |
| |
4778 |
| - | |
4779 |
| - | |
4780 |
| - | |
| 4778 | + | |
| 4779 | + | |
| 4780 | + | |
| 4781 | + | |
4781 | 4782 |
| |
4782 | 4783 |
| |
| 4784 | + | |
4783 | 4785 |
| |
4784 | 4786 |
| |
4785 | 4787 |
| |
| |||
5098 | 5100 |
| |
5099 | 5101 |
| |
5100 | 5102 |
| |
5101 |
| - | |
| 5103 | + | |
| 5104 | + | |
| 5105 | + | |
| 5106 | + | |
| 5107 | + | |
| 5108 | + | |
5102 | 5109 |
| |
5103 | 5110 |
| |
5104 | 5111 |
| |
|
Lines changed: 32 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3468 | 3468 |
| |
3469 | 3469 |
| |
3470 | 3470 |
| |
3471 |
| - | |
| 3471 | + | |
3472 | 3472 |
| |
3473 | 3473 |
| |
3474 | 3474 |
| |
| |||
3478 | 3478 |
| |
3479 | 3479 |
| |
3480 | 3480 |
| |
3481 |
| - | |
| 3481 | + | |
3482 | 3482 |
| |
3483 | 3483 |
| |
3484 | 3484 |
| |
| |||
3490 | 3490 |
| |
3491 | 3491 |
| |
3492 | 3492 |
| |
3493 |
| - | |
| 3493 | + | |
3494 | 3494 |
| |
3495 | 3495 |
| |
3496 |
| - | |
| 3496 | + | |
3497 | 3497 |
| |
3498 | 3498 |
| |
3499 | 3499 |
| |
| |||
3506 | 3506 |
| |
3507 | 3507 |
| |
3508 | 3508 |
| |
3509 |
| - | |
| 3509 | + | |
3510 | 3510 |
| |
3511 | 3511 |
| |
3512 | 3512 |
| |
3513 | 3513 |
| |
3514 | 3514 |
| |
3515 |
| - | |
| 3515 | + | |
3516 | 3516 |
| |
3517 | 3517 |
| |
3518 | 3518 |
| |
| 3519 | + | |
| 3520 | + | |
| 3521 | + | |
| 3522 | + | |
| 3523 | + | |
| 3524 | + | |
| 3525 | + | |
| 3526 | + | |
| 3527 | + | |
| 3528 | + | |
| 3529 | + | |
| 3530 | + | |
| 3531 | + | |
| 3532 | + | |
| 3533 | + | |
| 3534 | + | |
| 3535 | + | |
| 3536 | + | |
| 3537 | + | |
| 3538 | + | |
| 3539 | + | |
| 3540 | + | |
| 3541 | + | |
| 3542 | + | |
| 3543 | + | |
| 3544 | + | |
3519 | 3545 |
| |
3520 | 3546 |
| |
3521 | 3547 |
| |
|
Lines changed: 39 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2615 | 2615 |
| |
2616 | 2616 |
| |
2617 | 2617 |
| |
2618 |
| - | |
| 2618 | + | |
2619 | 2619 |
| |
2620 | 2620 |
| |
2621 | 2621 |
| |
| |||
2626 | 2626 |
| |
2627 | 2627 |
| |
2628 | 2628 |
| |
2629 |
| - | |
| 2629 | + | |
2630 | 2630 |
| |
2631 | 2631 |
| |
2632 | 2632 |
| |
| |||
2639 | 2639 |
| |
2640 | 2640 |
| |
2641 | 2641 |
| |
2642 |
| - | |
| 2642 | + | |
2643 | 2643 |
| |
2644 | 2644 |
| |
2645 | 2645 |
| |
2646 |
| - | |
| 2646 | + | |
2647 | 2647 |
| |
2648 | 2648 |
| |
2649 | 2649 |
| |
| |||
2657 | 2657 |
| |
2658 | 2658 |
| |
2659 | 2659 |
| |
2660 |
| - | |
| 2660 | + | |
2661 | 2661 |
| |
2662 | 2662 |
| |
2663 | 2663 |
| |
2664 | 2664 |
| |
2665 |
| - | |
| 2665 | + | |
2666 | 2666 |
| |
2667 | 2667 |
| |
2668 | 2668 |
| |
| 2669 | + | |
| 2670 | + | |
| 2671 | + | |
| 2672 | + | |
| 2673 | + | |
| 2674 | + | |
| 2675 | + | |
| 2676 | + | |
| 2677 | + | |
| 2678 | + | |
| 2679 | + | |
| 2680 | + | |
| 2681 | + | |
| 2682 | + | |
| 2683 | + | |
| 2684 | + | |
| 2685 | + | |
| 2686 | + | |
| 2687 | + | |
| 2688 | + | |
| 2689 | + | |
| 2690 | + | |
| 2691 | + | |
| 2692 | + | |
| 2693 | + | |
| 2694 | + | |
| 2695 | + | |
| 2696 | + | |
| 2697 | + | |
| 2698 | + | |
| 2699 | + | |
| 2700 | + | |
| 2701 | + | |
2669 | 2702 |
| |
2670 | 2703 |
| |
2671 | 2704 |
| |
|
0 commit comments
Comments
(0)