> For the complete documentation index, see [llms.txt](https://platform9.com/kb/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://platform9.com/kb/pmo/frequently-asked-questions/frequesnt-db-connection-errors-in-designate-logs.md).

# Frequent DB Connection Errors in Designate Logs

## Problem

Frequent db connection errors in the designate-mdns logs on the host with dns/designate role.

{% tabs %}
{% tab title="designate-mdns.logs" %}

```javascript
ERROR oslo_db.sqlalchemy.engines [req-927ce395-6d19-4caf-8d70-829d69003c28 - - - - -] Database connection was found disconnected; reconnecting: oslo_db.exception.DBConnectionError: (pymysql.err.OperationalError) (2006, "MySQL server has gone away (BrokenPipeError(32, 'Broken pipe'))")

ERROR oslo_db.sqlalchemy.engines [req-b2bd48e0-2a89-464d-84b3-9d2eefbfdae5 - - - - -] Database connection was found disconnected; reconnecting: oslo_db.exception.DBConnectionError: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server  during query')
```

{% endtab %}
{% endtabs %}

## Environment

* Platform9 Managed OpenStack - 5.8.0.
* Host having Designate role applied.

## Cause

When the Designate query communication with MySQL is using UDP instead of TCP, it is expected to see the `Lost connection to MySQL server during query` errors when the packets are missed as per the UDP protocol.

{% hint style="info" %}
**Info**

Using UDP protocol for the Designate to MySQL communication will not affect the overall transmission.
{% endhint %}

## Answer

To avoid the connection errors seen due to the packet losses as part of the UDP protocol, It is recommended to use TCP protocol, as it guarantee the successful communication- hence no "Lost connection" errors in the desinate logs.

{% hint style="info" %}
**Info**

If the connection pooling is used, make sure the connection lifetime (or timeout, etc) is less than the configured `wait_timeout`.
{% endhint %}

To enable TCP protocol for communication add `all_tcp = true` in the designate config file. The timeout value can be mentioned in the designate configuration file as mentioned below:

{% tabs %}
{% tab title="Designate config file" %}

```javascript
[service:mdns]
tcp_recv_timeout = 10          # Timeout value
all_tcp = true                 # To enable TCP protocol
listen = 0.0.0.0:5354
```

{% endtab %}
{% endtabs %}

## Additional Information

The error `"MySQL server has gone away (BrokenPipeError(32, 'Broken pipe'))")` are observed when the connections have been idle for longer than the database server's `wait_timeout`setting.

A solution to this is to set sqlalchemy's `pool_recycle` time to (significantly) less than the database's `wait_timeout` and use optimistic disconnect handling.

For more details, please refer the official documentation- [Connection Pooling — SQLAlchemy 2.0 Documentation](http://docs.sqlalchemy.org/en/rel_0_7/core/pooling.html?highlight=pool_recycle#setting-pool-recycle)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://platform9.com/kb/pmo/frequently-asked-questions/frequesnt-db-connection-errors-in-designate-logs.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
