Re: Conflict Detection and Resolution

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Dilip Kumar <dilipbalaut(at)gmail(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>, shveta malik <shveta(dot)malik(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, "Zhijie Hou (Fujitsu)" <houzj(dot)fnst(at)fujitsu(dot)com>, Nisha Moond <nisha(dot)moond412(at)gmail(dot)com>
Subject: Re: Conflict Detection and Resolution
Date: 2024-06-18 06:41:13
Message-ID: CAA4eK1KajO8K7dgCnV8x_VuQVptxMh8XFW75WejdT62CV_69cg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Jun 18, 2024 at 11:54 AM Dilip Kumar <dilipbalaut(at)gmail(dot)com> wrote:
>
> On Mon, Jun 17, 2024 at 8:51 PM Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> >
> > On Mon, Jun 17, 2024 at 1:42 AM Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
> > > The difference w.r.t the existing mechanisms for holding deleted data
> > > is that we don't know whether we need to hold off the vacuum from
> > > cleaning up the rows because we can't say with any certainty whether
> > > other nodes will perform any conflicting operations in the future.
> > > Using the example we discussed,
> > > Node A:
> > > T1: INSERT INTO t (id, value) VALUES (1,1);
> > > T2: DELETE FROM t WHERE id = 1;
> > >
> > > Node B:
> > > T3: UPDATE t SET value = 2 WHERE id = 1;
> > >
> > > Say the order of receiving the commands is T1-T2-T3. We can't predict
> > > whether we will ever get T-3, so on what basis shall we try to prevent
> > > vacuum from removing the deleted row?
> >
> > The problem arises because T2 and T3 might be applied out of order on
> > some nodes. Once either one of them has been applied on every node, no
> > further conflicts are possible.
>
> If we decide to skip the update whether the row is missing or deleted,
> we indeed reach the same end result regardless of the order of T2, T3,
> and Vacuum. Here's how it looks in each case:
>
> Case 1: T1, T2, Vacuum, T3 -> Skip the update for a non-existing row
> -> end result we do not have a row.
> Case 2: T1, T2, T3 -> Skip the update for a deleted row -> end result
> we do not have a row.
> Case 3: T1, T3, T2 -> deleted the row -> end result we do not have a row.
>

In case 3, how can deletion be successful? The row required to be
deleted has already been updated.

--
With Regards,
Amit Kapila.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2024-06-18 06:43:50 Re: State of pg_createsubscriber
Previous Message Peter Smith 2024-06-18 06:40:36 DOCS: Generated table columns are skipped by logical replication