# Frequent sporadic "MySQL server has gone away" errors with Operator for MySQL (XtraDB Cluster) and HAProxy

**URL:** <https://forums.percona.com/t/frequent-sporadic-mysql-server-has-gone-away-errors-with-operator-for-mysql-xtradb-cluster-and-haproxy/37974>\
**Category:** Percona Operator for MySQL\
**Created:** [May 16, 2025, 8:02am UTC](https://forums.percona.com/t/frequent-sporadic-mysql-server-has-gone-away-errors-with-operator-for-mysql-xtradb-cluster-and-haproxy/37974 "2025-05-16T08:02:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jhwalker](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/jhwalker/32/20260_2.png) [@jhwalker](https://forums.percona.com/u/jhwalker)\
**Post date:** [May 16, 2025, 8:02am UTC](https://forums.percona.com/t/frequent-sporadic-mysql-server-has-gone-away-errors-with-operator-for-mysql-xtradb-cluster-and-haproxy/37974/1 "2025-05-16T08:02:00Z")

</div>

## Description:

We are running a Percona Operator for MySQL (XtraDB Cluster) cluster with 3 PXC replicas and 3 HAProxy replicas. This cluster is serving a PHP application that connects using PDO to the `<cluster-name>-haproxy` service.

The cluster appears to be healthy; however every few minutes we see an error like this (as reported from PHP):

```auto
SQLSTATE[HY000]: General error: 2006 MySQL server has gone away

```

Sometimes, this message is seen instead:

```auto
SQLSTATE[08S01]: Communication link failure: 1158 Got an error reading communication packets

```

## Debugging attempted so far

We disabled HAProxy and connected directly to the `<cluster-name>-pxc` service instead. With this change applied, no further errors were encountered during the whole time the change was live. On switching back to `<cluster-name>-haproxy`, the errors have begun again.

We are using the default HAProxy config provided by the operator and I’m unsure where to start in trying to resolve this problem. I checked the HAProxy logs and there are a mixture of `CD` and `SD` error codes for `termination_state` (as far as I can see), e.g.:

```auto
[pod/mysql-haproxy-0/haproxy] {"time":"16/May/2025:07:52:20.337", "client_ip": "10.244.6.140", "client_port":"35524", "backend_source_ip": "10.244.7.208", "backend_source_port": "34858", "frontend_name": "galera-in", "backend_name": "galera-nodes", "server_name":"mysql-pxc-0", "tw": "1", "tc": "1", "Tt": "2", "bytes_read": "83", "termination_state": "SD", "actconn": "233", "feconn" :"232", "beconn": "231", "srv_conn": "231", "retries": "0", "srv_queue": "0", "backend_queue": "0" }

[pod/mysql-haproxy-0/haproxy] {"time":"16/May/2025:07:47:07.227", "client_ip": "10.244.6.140", "client_port":"46498", "backend_source_ip": "10.244.7.208", "backend_source_port": "40846", "frontend_name": "galera-in", "backend_name": "galera-nodes", "server_name":"mysql-pxc-0", "tw": "1", "tc": "148", "Tt": "318405", "bytes_read": "1189188", "termination_state": "CD", "actconn": "245", "feconn" :"244", "beconn": "243", "srv_conn": "243", "retries": "0", "srv_queue": "0", "backend_queue": "0" }

```

Any guidance on what to change to solve this would be very much appreciated please, as these errors are coming in regularly.

## Version:

- _Operator:_ 1.15.0
- _PXC:_ percona/percona-xtradb-cluster:8.0.35
- _HAProxy:_ percona/haproxy:2.8.5

---

<div class="post-metadata">

**Author:** ![Slava\_Sarzhan](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/slava_sarzhan/32/3196_2.png) [@Slava\_Sarzhan](https://forums.percona.com/u/Slava_Sarzhan)\
**Post date:** [May 16, 2025, 11:07am UTC](https://forums.percona.com/t/frequent-sporadic-mysql-server-has-gone-away-errors-with-operator-for-mysql-xtradb-cluster-and-haproxy/37974/2 "2025-05-16T11:07:31Z")

</div>

> [@jhwalker](#):
>
> `General error: 2006 MySQL server has gone away`

Hi @jhwalker, please check this task [Jira](https://perconadev.atlassian.net/browse/PXC-4388)  
Do you have any errors/warnings in PXC log?

---

<div class="post-metadata">

**Author:** ![jhwalker](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/jhwalker/32/20260_2.png) [@jhwalker](https://forums.percona.com/u/jhwalker)\
**Post date:** [May 16, 2025, 2:25pm UTC](https://forums.percona.com/t/frequent-sporadic-mysql-server-has-gone-away-errors-with-operator-for-mysql-xtradb-cluster-and-haproxy/37974/3 "2025-05-16T14:25:42Z")

</div>

> [@Slava\_Sarzhan](#):
>
> please check this task [Jira](https://perconadev.atlassian.net/browse/PXC-4388)

Thanks for the reply; unfortunately, it looks like I can’t see this task:

 ![image](https://us1.discourse-cdn.com/flex019/uploads/percona1/original/3X/8/7/8744ff7cd76ab1b6de4c8bb03e590f5f07648b3f.png)

_(Logged into JIRA using my forum email address)_

> [@Slava\_Sarzhan](#):
>
> Do you have any errors/warnings in PXC log?

There were no errors or warnings showing in the log.

* * *

Please let me know any other information you need to help. We are currently bypassing HAProxy again because this is a production service with PHP serving up to 100 reqs/second in peak time. We see typically about 1-2 errors per minute, sometimes more, so a very small percentage of overall requests, but enough to impact users and drown us in error reports.

We can start to use HAProxy again temporarily to collect debugging data. In the meantime, we are connecting to PXC via a custom Kubernetes Service that always targets the `<cluster-name>-pxc-0` Pod; we will failover manually by updating the Service’s selector if the `-0` Pod fails and we need to switch to a replica.

---

<div class="post-metadata">

**Author:** ![jhwalker](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/jhwalker/32/20260_2.png) [@jhwalker](https://forums.percona.com/u/jhwalker)\
**Post date:** [May 22, 2025, 7:32pm UTC](https://forums.percona.com/t/frequent-sporadic-mysql-server-has-gone-away-errors-with-operator-for-mysql-xtradb-cluster-and-haproxy/37974/4 "2025-05-22T19:32:00Z")

</div>

@Slava_Sarzhan did you get a chance to check my reply above please?

Just wondering if that JIRA task may include relevant info or not, as I couldn’t access it. I’m still trying to get to the bottom of this problem.

I’ve attached a log file excerpt from `mysql-pxc-0` Pod from earlier in the week, when we briefly started using HAProxy again (still giving errors).

[log.txt](https://forums.percona.com/uploads/short-url/q7AcDS4Wh9K995HGT00VngjgkpN.txt) (87.9 KB)

---

<div class="post-metadata">

**Author:** ![Thijmen\_Stavenuiter](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/thijmen_stavenuiter/32/21804_2.png) [@Thijmen\_Stavenuiter](https://forums.percona.com/u/Thijmen_Stavenuiter)\
**Post date:** [August 15, 2025, 8:42am UTC](https://forums.percona.com/t/frequent-sporadic-mysql-server-has-gone-away-errors-with-operator-for-mysql-xtradb-cluster-and-haproxy/37974/5 "2025-08-15T08:42:17Z")

</div>

@Slava_Sarzhan curious here too, we’re experiencing this too. Any insights?
