On Fri, 2019-10-04 at 00:34 +1000, Jason Wang wrote:
> I read this
> https://www.2ndquadrant.com/en/blog/evolution-fault-tolerance-postgresql-synchronous-commit/
>
> But don't see why your primary would have more records than the
> standby?
>
> If killall was issued before commit returned, that means the
> transaction wasn't completed so yes you would lose records after last
> commit but that's expected; if commit was returned both primary and
> standby should have the transaction.
>
> Are you sure in your case you end up with primary and standby with
> different records from a single transaction?
PostgreSQL synchronous streaming replicatoin doesn't use anything like
two-phase commit.
1. It commits the transaction locally first, which generates WAL.
2. The WAL gets replicated.
3. As soon as the standby reports success, COMMIT returns.
If there is a failure after the first step completed, the
transaction will be committed locally, but not on the standby.
Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com