Why does my Kubernetes Service keep connecting to a dead PXC node?

November 13, 2026 5 answers
Asked by 9t+windchime_73

I have a three-node, air-gapped K3s cluster with a three-node Percona XtraDB Cluster. Each database pod runs on a different node. I disabled HAProxy and ProxySQL and created a ClusterIP Service that selects the database pods.

After powering off one node, the application kept trying to connect to its database pod, even after I recreated the application pod. I expected new connections to go to a surviving pod. What should I check, and can this work without changing the application?

Answers

Brelby.8

First check the pod conditions and the Service's EndpointSlices after the power-off. A hard shutdown doesn't give the kubelet a chance to report that its pod is no longer ready. Node failure detection and pod eviction take time, so the failed pod can remain an eligible endpoint for a while.

Look at the node conditions, pod readiness, EndpointSlice ready conditions, and the pod's not-ready and unreachable tolerations. The common default toleration is around five minutes, but don't assume that exact delay applies to your setup. Watch when the endpoint actually changes rather than just checking that its IP is listed.

waltz.404-ish:

Also check the Service's publishNotReadyAddresses setting. That can change how readiness is represented for its endpoints.

Reply to this answer
Durnip

A ClusterIP Service does forward traffic to selected endpoints, but it doesn't perform its own MySQL health checks or understand PXC quorum. Kubernetes generally relies on pod readiness to decide which endpoints should receive normal Service traffic.

Check what the operator's readiness probe actually tests and whether it distinguishes a usable database member from one that is running but unable to serve the application's traffic. A TCP port being open alone would not establish that.

Reply to this answer
Mallowby

The Service chooses a backend for a connection. It cannot move an existing MySQL connection or an in-flight transaction to another pod when that backend dies. The client still needs to notice the failure and reconnect, and transaction retry behavior needs care.

Recreating the application pod rules out some old connections, but it doesn't prove the dead endpoint was removed before the new connections were made. Check the endpoint conditions at the time of those attempts.

9t+windchime_73:

So a fresh application pod can still hit the failed address if Kubernetes hasn't marked that endpoint ineligible yet?

v31!parcel_8:

Yes. And removing the endpoint affects new connection selection, not an existing connection that was already using it.

Reply to this answer
narrowly.elsewhere

I'd reconsider the operator's HAProxy or ProxySQL option rather than treating a plain Service as a database-aware failover layer. A proxy may provide a stable address for the application while checking and selecting database backends. Review the operator configuration and proxy health checks to see whether that fits your requirements.

It still won't make a broken connection or interrupted transaction magically survive. Whether you can avoid application changes depends on how the application handles disconnects and reconnects.

Reply to this answer
~briefly!off+course

One connection attempt going to a dead endpoint doesn't tell you much about the other two. Check Service session affinity and test several genuinely new TCP connections while recording the EndpointSlice conditions and timing. If every connection still lands on the failed address, inspect the Service configuration and networking implementation rather than assuming random selection guarantees an even spread.

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions