Questions about SyncRepWaitForLSN()

From: Paul Guo <pguo(at)pivotal(dot)io>
To: PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Questions about SyncRepWaitForLSN()
Date: 2019-12-16 07:37:41
Message-ID: CAEET0ZHG5oFF7iEcbY6TZadh1mosLmfz1HLm311P9VOt7Z+jeg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello pg hackers,

This is the definition of the function:

SyncRepWaitForLSN(XLogRecPtr lsn, bool commit)

1. In the code, it emits ereport(WARNING) for the
ProcDiePending/QueryCancelPending case like this:

ereport(WARNING,
(errcode(ERRCODE_ADMIN_SHUTDOWN),
errmsg("canceling the wait for synchronous
replication and terminating connection due to administrator command"),
errdetail("The transaction has already committed
locally, but might not have been replicated to the standby.")));

The message "The transaction has already committed locally" is wrong
for non-commit waiting e.g. 2PC Prepare or AbortPrepare, right? so maybe we
just give the errdtail for the commit==true case.

2. I'm curious how the client should proceed for the ProcDiePending corner
case in the function (assuming synchronous_commit as remote_write or
above). In this scenario, a transaction has been committed locally on
master but we are not sure if the commit is replicated to standby or not if
ProcDiePending happens. The commit is not in a safe status from the
perspective of HA, for example if further when auto-failover happens, we
may or may not lose the transaction commit on the standby and client just
gets (and even can not get) a warning of unknown commit replication status.

Thanks.

Browse pgsql-hackers by date

  From Date Subject
Next Message Etsuro Fujita 2019-12-16 08:19:36 Re: Unmatched test and comment in partition_join.sql regression test
Previous Message Thomas Munro 2019-12-16 06:42:33 Re: What's the best way to get flex and bison on Windows?