Questions about SyncRepWaitForLSN() - Mailing list pgsql-hackers

From Paul Guo
Subject Questions about SyncRepWaitForLSN()
Date
Msg-id CAEET0ZHG5oFF7iEcbY6TZadh1mosLmfz1HLm311P9VOt7Z+jeg@mail.gmail.com
Whole thread Raw
List 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.

pgsql-hackers by date:

Previous
From: Thomas Munro
Date:
Subject: Re: What's the best way to get flex and bison on Windows?
Next
From: Etsuro Fujita
Date:
Subject: Re: Unmatched test and comment in partition_join.sql regression test