xbzhang <xbzhang@kingbase.com.cn> writes:
> LWlocks can record in resource owner per tuples, so they can be released at rigth way, but the memory allocated on
memorycontext is one problem.Are there any others problems?
See AbortSubTransaction(), CleanupSubTransaction(), and the rather large
number of subroutines they call. Almost everything that code does is
connected to cleaning up something that might have been left unfinished
after an elog(ERROR) took control away in the middle of some code
sequence.
In addition, you can't just wave your hands and presto the bad tuple is
not there anymore. For example, the failure might have been a unique key
violation in some index or other. Not only is the bad tuple already on
disk, but possibly so are index entries for it in other indexes. In
general the only way to get rid of those index entries is a VACUUM.
So you really have to have a subtransaction whose XID is what you mark
the new tuple with, and then rolling back the subtransaction is what
causes the new tuple to not be seen as good. (Actually getting rid of
it will be left for the next VACUUM.)
regards, tom lane