From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | thomas(dot)d(dot)mckay(at)gmail(dot)com |
Cc: | Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, pgsql-bugs(at)lists(dot)postgresql(dot)org |
Subject: | Re: BUG #17607: Server process crashes when PLpgSQL function raises error in subtransaction |
Date: | 2022-09-25 18:24:07 |
Message-ID: | 3065565.1664130247@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
I wrote:
> PG Bug reporting form <noreply(at)postgresql(dot)org> writes:
>> I've encountered a bug while doing some SQL migrations on a PostgreSQL 13.8
>> server. My initial use-case is a Django app running migrations, a test setup
>> and a test, but that code was more than 10K lines of DDL, so I've reduced
>> the code to a minimal reproducible example (as best I could).
> Thanks for the minimal reproducer! I confirm that this problem is visible
> in the v12 and v13 branches, but not before or after.
I got a chance to look at this today, and what I find is that we're making
a tuple slot that will be freed at end of subtransaction, but it has a
refcount on a refcounted tuple descriptor that belongs to the Portal's
resowner. While trying to free the slot, we get a complaint because the
subtransaction's resowner isn't holding the appropriate tupdesc reference.
It seems to me there are probably other hazards here, because the tupdesc
could possibly also go away before the slot does. I think what we ought
to do is copy the tupdesc, so that we have a non-refcounted descriptor
that we know has exactly the right lifespan. As attached.
Not sure about whether to bother with a test case. The submitted
reproducer doesn't work in >= v14, and even in v12/v13 it seems awfully
corner-case-ish. (I find for instance that you need the ALTER TABLE
step rather than just making the table in one step, and I'm a tad
baffled as to why.) In any case, I've got zero faith that there are
not other ways to trigger the same problem, so I think we need to apply
this up to HEAD.
regards, tom lane
Attachment | Content-Type | Size |
---|---|---|
fix-trigger-tupdesc-refcount-issue.patch | text/x-diff | 968 bytes |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2022-09-25 19:01:15 | Re: BUG #17607: Server process crashes when PLpgSQL function raises error in subtransaction |
Previous Message | Tom Lane | 2022-09-24 20:57:51 | Re: BUG #17385: "RESET transaction_isolation" inside serializable transaction causes Assert at the transaction end |