Michael Paquier <michael.paqu...@gmail.com> writes: > Finally I have been able to crack down the problem, and it can be > reproduced with the following test case for example:
Hm. It looks like the problem is that we're executing the function within the Portal created for cursor "h", and that Portal is older than the subtransaction created by the savepoint, so when we abort the subtransaction we do not clean up the Portal. That means that resources held by that Portal haven't been released --- in particular it still has a relcache pin on the "new_table" --- when subtransaction abort gets to the point of wanting to drop relcache entries created during the subtransaction. So the Assert has caught an actual problem: we'd have flushed the relcache entry while there was still an open reference to it. I'm inclined to think that the only real fix for this type of problem is that at subtransaction abort, we have to prevent further execution of any Portals that have executed at all within the subxact (ie force them into PORTAL_FAILED state and clean out their resources, see MarkPortalFailed). It's not good enough to kill the one(s) that are actively executing at the instant of failure, because anything that's run at all since the subxact started might be holding a reference to an object we're about to delete. I'm a little worried that that will break usage patterns that work today, though. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers