Re: How to implement the skip errors for copy from ? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: How to implement the skip errors for copy from ?
Date
Msg-id 16380.1403012443@sss.pgh.pa.us
Whole thread Raw
In response to Re: How to implement the skip errors for copy from ?  (xbzhang <xbzhang@kingbase.com.cn>)
List pgsql-hackers
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



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: Wait free LW_SHARED acquisition - v0.2
Next
From: Tom Lane
Date:
Subject: Re: UPDATE SET (a,b,c) = (SELECT ...) versus rules