Re: sequences vs. synchronous replication

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: sequences vs. synchronous replication
Date: 2021-12-18 04:52:48
Message-ID: 1452362.1639803168@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com> writes:
> The problem is exactly the same as in [1] - the aborted transaction
> generated WAL, but RecordTransactionAbort() ignores that and does not
> update LogwrtResult.Write, with the reasoning that aborted transactions
> do not matter. But sequences violate that, because we only write WAL
> once every 32 increments, so the following nextval() gets "committed"
> without waiting for the replica (because it did not produce WAL).

Ugh.

> I'm not sure this is a clear data corruption bug, but it surely walks
> and quacks like one. My proposal is to fix this by tracking the lsn of
> the last LSN for a sequence increment, and then check that LSN in
> RecordTransactionCommit() before calling XLogFlush().

(1) Does that work if the aborted increment was in a different
session? I think it is okay but I'm tired enough to not be sure.

(2) I'm starting to wonder if we should rethink the sequence logging
mechanism altogether. It was cool when designed, but it seems
really problematic when you start thinking about replication
behaviors. Perhaps if wal_level > minimal, we don't do things
the same way?

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2021-12-18 06:00:45 Re: sequences vs. synchronous replication
Previous Message Amit Kapila 2021-12-18 04:07:02 Re: Column Filtering in Logical Replication