Haproxy is not stopping connections after failover from pxc-2 to pxc-0

Description

  1. Create the cluster (I’m using ./anydbver deploy k8s-pxc:1.13.0 , default cr.yaml with RollingUpdate)

  2. Put pxc-0 down: kubectl -n pxc exec -it cluster1-pxc-0 -c pxc -- bash -c 'touch /var/lib/mysql/sleep-forever;mysql -uroot -p"$MYSQL_ROOT_PASSWORD" -e shutdown'

  3. Connect via haproxy: kubectl -n pxc exec -it cluster1-pxc-2 -c pxc -- bash ; mysql -uroot -p$MYSQL_ROOT_PASSWORD -h cluster1-haproxy

  4. SELECT @hostname returns pxc-2

  5. Fix pxc-0: kubectl -n pxc exec -it cluster1-pxc-0 -c pxc -- rm -f /var/lib/mysql/sleep-forever

  6. New connections going to pxc-0, but existing connections still able to execute DML/DDL queries on pxc-2

The issue could be fixed by adding hard-stop-after 10s

to the global haproxy configuration

Environment

None

Activity

Show:

Nickolay Ihalainen December 22, 2023 at 12:43 PM

correct, after 10 seconds connection will be closed and primary role fully switches to pxc-0. Existing queries are rolled back and application could retry the transaction. PXC is not supporting single primary mode and such urgent shutdown prevents performance drops/transaction rollbacks (due to optimistic locking).

ege.gunes December 22, 2023 at 11:38 AM

I confirm that the problem happens and hard-stop-after 10s fixes the issue. But we still have a 10 second time window that the query can still end up in pod-2 right?

Done

Details

Assignee

Reporter

Needs QA

Yes

Fix versions

Affects versions

Priority

Smart Checklist

Created December 21, 2023 at 6:28 PM
Updated March 4, 2024 at 2:41 PM
Resolved January 15, 2024 at 12:43 PM