Обсуждение: Questions about SyncRepWaitForLSN()

Поиск
Список
Период
Сортировка

Questions about SyncRepWaitForLSN()

От
Paul Guo
Дата:
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.