Re: Documenting when to retry on serialization failure

From: Simon Riggs <simon(dot)riggs(at)enterprisedb(dot)com>
To: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Documenting when to retry on serialization failure
Date: 2022-03-24 12:12:56
Message-ID: CANbhV-HX+6OgRxvQ-sRG3Krro7=F7=mu-gX_qiKqsJfYo=LEjw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, 24 Mar 2022 at 11:01, Thomas Munro <thomas(dot)munro(at)gmail(dot)com> wrote:
>
> On Thu, Mar 24, 2022 at 11:44 PM Simon Riggs
> <simon(dot)riggs(at)enterprisedb(dot)com> wrote:
> > The unique violation thing is worryingly general. Do we know enough to
> > say that this is thought to occur only with a) multiple unique
> > constraints, b) exclusion constraints?
>
> I'm aware of 3 cases. The two you mentioned, which I think we can fix
> (as described in the threads I posted upthread), and then there is a
> third case that I'm still confused about, in the last line of
> read-write-unique-4.spec.

I don't see any confusion - it is clearly a serialization error. What
is more, I see this as a confusing bug that we should fix.

If we were updating the row rather than inserting it, we would get
"ERROR: could not serialize access due to concurrent update", as
documented. The type of command shouldn't affect whether it is a
serialization error or not. (Attached patch proves it does throw
serializable error for UPDATE).

Solving this requires us to alter the Index API to pass down a
snapshot to allow us to test whether the concurrent insert is visible
or not. The test is shown in the attached patch, but this doesn't
attempt the major task of tweaking the APIs to allow this check to be
made.

--
Simon Riggs http://www.EnterpriseDB.com/

Attachment Content-Type Size
partial_patch_for_read-write-unique-4_serialization_error.v1.patch application/octet-stream 1.1 KB
isotest_read-write-unique-5.v1.patch application/octet-stream 4.0 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message David Christensen 2022-03-24 12:43:02 Re: [PATCH] add relation and block-level filtering to pg_waldump
Previous Message Tomas Vondra 2022-03-24 12:12:24 Re: pg_stat_reset_single_*_counters vs pg_stat_database.stats_reset