From: Laurenz Albe <laurenz.albe@cybertec.at>
To: qihua wu <staywithpin@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: invisible commit question for sync replication
Date: Wed, 01 Feb 2023 09:38:27 +0100
Message-ID: <49ef95ee06cb0d94af198cac331f7bc39d743619.camel@cybertec.at> (raw)
In-Reply-To: <CAPoYtoLLjg1rPLNsPoF5E4dAPgGaMnBEpxP-yW8xjgGkm1q16w@mail.gmail.com>
References: <CAPoYtoLLjg1rPLNsPoF5E4dAPgGaMnBEpxP-yW8xjgGkm1q16w@mail.gmail.com>
On Wed, 2023-02-01 at 14:52 +0800, qihua wu wrote:
> When run a cluster with sync replication, if DML is done on primary, but primary is
> isolated from all slave, then the DML will hang, if cancel it DML, it will say:
> WARNING: canceling wait for synchronous replication due to user request
> DETAIL: The transaction has already committed locally, but might not have been replicated to the standby
>
> So the workflow is
> 1: commit to local.
> 2: waiting for ACK from remote sync.
>
> When cancel the DML at step 2. the data are arealy on local, that's why it's warning.
>
> But when runs an insert which is waiting for remote ACK, and then query from another
> session, I didn't find that row. Why this happen? If the insert is already one locally,
> whey another session can't read it?
COMMIT is not as atomic as it appears. When the backend is waiting for the standby,
it has already committed the transaction on disk, but that fact is not advertised to
the other backends yet.
Yours,
Laurenz Albe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: laurenz.albe@cybertec.at, staywithpin@gmail.com
Subject: Re: invisible commit question for sync replication
In-Reply-To: <49ef95ee06cb0d94af198cac331f7bc39d743619.camel@cybertec.at>
References: <CAPoYtoLLjg1rPLNsPoF5E4dAPgGaMnBEpxP-yW8xjgGkm1q16w@mail.gmail.com> <49ef95ee06cb0d94af198cac331f7bc39d743619.camel@cybertec.at>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox