Re: Concurrency bug in UPDATE of partition-key - Mailing list pgsql-hackers

From Amit Kapila
Subject Re: Concurrency bug in UPDATE of partition-key
Date
Msg-id CAA4eK1JgsDnx9YdwGZKM_PzVFbMoFP7z+-Tx58TKsxZzuiDbng@mail.gmail.com
Whole thread Raw
In response to Re: Concurrency bug in UPDATE of partition-key  (Amit Khandekar <amitdkhan.pg@gmail.com>)
Responses Re: Concurrency bug in UPDATE of partition-key
List pgsql-hackers
On Tue, Jun 5, 2018 at 8:03 PM, Amit Khandekar <amitdkhan.pg@gmail.com> wrote:
Attached is a rebased patch version. Also included it in the upcoming
commitfest :
https://commitfest.postgresql.org/18/1660/


Doesn't this belong to PostgreSQL 11 Open Items [1] or are you proposing it as a feature enhancement for next version?
 
In the rebased version, the new test cases are added in the existing
isolation/specs/partition-key-update-1.spec test.


  if (!tuple_deleted)
- return NULL;
+ {
+ /*
+ * epqslot will be typically NULL. But when ExecDelete() finds
+ * that another transaction has concurrently updated the same
+ * row, it re-fetches the row, skips the delete, and epqslot is
+ * set to the re-fetched tuple slot. In that case, we need to
+ * do all the checks again.
+ */
+ if (TupIsNull(epqslot))
+ return NULL;
+ else
+ {
+ slot = ExecFilterJunk(resultRelInfo->ri_junkFilter, epqslot);
+ tuple = ExecMaterializeSlot(slot);
+ goto lreplace;
+ }
+ }

I think this will allow before row delete triggers to be fired more than once.  Normally, if the EvalPlanQual testing generates a new tuple, we don't fire the triggers again.  Now, one possibility could be that we don't skip the delete after a concurrent update and still allow inserts to use a new tuple generated by EvalPlanQual testing of delete.  However, I think we need to perform rechecks for update to check if the modified tuple still requires to be moved to new partition, right or do you have some other reason in mind?



--
With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com

pgsql-hackers by date:

Previous
From: David Rowley
Date:
Subject: Re: Needless additional partition check in INSERT?
Next
From: "Tsunakawa, Takayuki"
Date:
Subject: RE: I'd like to discuss scaleout at PGCon