From: | Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com> |
---|---|
To: | Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: sequences vs. synchronous replication |
Date: | 2021-12-22 01:57:02 |
Message-ID: | 4450cd74-1a41-ec03-83ee-fcabc183715d@enterprisedb.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 12/19/21 04:03, Amit Kapila wrote:
> On Sat, Dec 18, 2021 at 7:24 AM Tomas Vondra
> <tomas(dot)vondra(at)enterprisedb(dot)com> wrote:
>>
>> while working on logical decoding of sequences, I ran into an issue with
>> nextval() in a transaction that rolls back, described in [1]. But after
>> thinking about it a bit more (and chatting with Petr Jelinek), I think
>> this issue affects physical sync replication too.
>>
>> Imagine you have a primary <-> sync_replica cluster, and you do this:
>>
>> CREATE SEQUENCE s;
>>
>> -- shutdown the sync replica
>>
>> BEGIN;
>> SELECT nextval('s') FROM generate_series(1,50);
>> ROLLBACK;
>>
>> BEGIN;
>> SELECT nextval('s');
>> COMMIT;
>>
>> The natural expectation would be the COMMIT gets stuck, waiting for the
>> sync replica (which is not running), right? But it does not.
>>
>
> How about if we always WAL log the first sequence change in a transaction?
>
I've been thinking about doing something like this, but I think it would
not have any significant advantages compared to using "SEQ_LOG_VALS 0".
It would still have the same performance hit for plain nextval() calls,
and there's no measurable impact on simple workloads that already write
WAL in transactions even with SEQ_LOG_VALS 0.
regards
--
Tomas Vondra
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
From | Date | Subject | |
---|---|---|---|
Next Message | Masahiko Sawada | 2021-12-22 02:39:00 | Re: do only critical work during single-user vacuum? |
Previous Message | Dilip Kumar | 2021-12-22 01:50:22 | Re: Checkpointer crashes with "PANIC: could not fsync file "pg_tblspc/.." |