|From:||Andrey Borodin <x4mmm(at)yandex-team(dot)ru>|
|To:||PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>|
|Subject:||Disallow cancellation of waiting for synchronous replication|
|Views:||Raw Message | Whole Thread | Download mbox | Resend email|
This is continuation of thread  in pgsql-general with proposed changes. As Maksim pointed out, this topic was raised before here .
Currently, we can have split brain with the combination of following steps:
0. Setup cluster with synchronous replication. Isolate primary from standbys.
1. Issue upsert query INSERT .. ON CONFLICT DO NOTHING
2. CANCEL 1 during wait for synchronous replication
3. Retry 1. Idempotent query will succeed and client have confirmation of written data, while it is not present on any standby.
Thread  contain reproduction from psql.
In certain situations we cannot avoid cancelation of timed out queries. Yes, we can interpret warnings and thread them as errors, but warning is emitted on step 1, not on step 3.
I think proper solution here would be to add GUC to disallow cancellation of synchronous replication. Retry step 3 will wait on locks after hanging 1 and data will be consistent.
Three is still a problem when backend is not canceled, but terminated . Ideal solution would be to keep locks on changed data. Some well known databases threat termination of synchronous replication as system failure and refuse to operate until standbys appear (see Maximum Protection mode). From my point of view it's enough to PANIC once so that HA tool be informed that something is going wrong.
Anyway situation with cancelation is more dangerous. We've observed it in some user cases.
Please find attached draft of proposed change.
Best regards, Andrey Borodin.
|Next Message||Simon Riggs||2019-12-20 05:46:43||Re: Optimizing TransactionIdIsCurrentTransactionId()|
|Previous Message||Yugo Nagata||2019-12-20 05:02:32||Re: Implementing Incremental View Maintenance|