@Srinivas
synchronous_mode_strict maintains strict consistency and requires at least one synchronous replica to allow commits or write request.
This parameter prevents Patroni from switching off the synchronous replication on the primary when no synchronous standby candidates are available. As a downside, the primary is not be available for writes (unless the Postgres transaction explicitly turns off synchronous_commit), blocking all client write requests until at least one synchronous replica comes up
I tried deleting one of the sync pods [cluster1-instance1-gmx5-0] with --force and observed a few seconds stall on leader write.
sh-5.1$ patronictl list
+ Cluster: cluster1-ha (7654234399595749491) -------------------------+--------------+-----------+----+-------------+-----+------------+-----+
| Member | Host | Role | State | TL | Receive LSN | Lag | Replay LSN | Lag |
+---------------------------+-----------------------------------------+--------------+-----------+----+-------------+-----+------------+-----+
| cluster1-instance1-bv44-0 | cluster1-instance1-bv44-0.cluster1-pods | Replica | streaming | 2 | 0/18000000 | 0 | 0/18000000 | 0 |
**| cluster1-instance1-gmx5-0 | cluster1-instance1-gmx5-0.cluster1-pods | Sync Standby | streaming | 2 | 0/18000000 | 0 | 0/18000000 | 0 |**
| cluster1-instance1-mwsw-0 | cluster1-instance1-mwsw-0.cluster1-pods | Leader | running | 2 | | | | |
+---------------------------
kubectl delete pod cluster1-instance1-gmx5-0 --force -n postgres-operator
Warning: Immediate deletion does not wait for confirmation that the running resource has been terminated. The resource may continue to run on the cluster indefinitely.
pod "cluster1-instance1-gmx5-0" force deleted
That stall happens because sync replica[cluster1-instance1-gmx5-0] was stopped for that movement.
sh-5.1$ patronictl list
+ Cluster: cluster1-ha (7654234399595749491) -------------------------+--------------+-----------+----+-------------+-----+------------+-----+
| Member | Host | Role | State | TL | Receive LSN | Lag | Replay LSN | Lag |
+---------------------------+-----------------------------------------+--------------+-----------+----+-------------+-----+------------+-----+
| cluster1-instance1-bv44-0 | cluster1-instance1-bv44-0.cluster1-pods | Replica | streaming | 2 | 0/1A0000D0 | 0 | 0/1A0000D0 | 0 |
**| cluster1-instance1-gmx5-0 | cluster1-instance1-gmx5-0.cluster1-pods | Sync Standby | stopped | | unknown | | unknown | |**
| cluster1-instance1-mwsw-0 | cluster1-instance1-mwsw-0.cluster1-pods | Leader | running | 2 | | | | |
+---------------------------+-----------------------------------------+--------------+-----------+----+-------------+-----+------------+-----+
Here, the leader continues waiting for acknowledgements from the sync standby, which was down.
Later once it available the writes works fine.
sh-5.1$ patronictl list
+ Cluster: cluster1-ha (7654234399595749491) -------------------------+--------------+-----------+----+-------------+-----+------------+-----+
| Member | Host | Role | State | TL | Receive LSN | Lag | Replay LSN | Lag |
+---------------------------+-----------------------------------------+--------------+-----------+----+-------------+-----+------------+-----+
| cluster1-instance1-bv44-0 | cluster1-instance1-bv44-0.cluster1-pods | Replica | streaming | 2 | 0/1B000000 | 0 | 0/1B000000 | 0 |
| cluster1-instance1-gmx5-0 | cluster1-instance1-gmx5-0.cluster1-pods | Sync Standby | streaming | 2 | 0/1B000000 | 0 | 0/1B000000 | 0 |
| cluster1-instance1-mwsw-0 | cluster1-instance1-mwsw-0.cluster1-pods | Leader | running | 2 | | | | |
+---------------------------+-----------------------------------------+--------------+-----------+----+-------------+-----+------------+-----+
sh-5.1$
The fact is, with that instant delete [–force], it immediately removes resources from the API and bypasses graceful deletion. This most likely doesn’t allow time to switch sync mode on other available Replica [cluster1-instance1-bv44-0] or still the writes consider old Sync node for some time frame.
–force
If true, immediately remove resources from API and bypass graceful deletion. Note that immediate deletion of some resources may result in inconsistency or data loss and requires confirmation.
kubectl delete | Kubernetes
Your observation is correct. With graceful deletion, it works fine, and we didn’t observe this issue.
Can you please share the patronictl output below to take a quick look at the member roles sync staus?
kubectl exec -it <cluster> -n postgres-operator -- sh
patronictl list