Skip to content

Commit eade982

Browse files
authored
Merge pull request pallets-eco#416 from nickw444/mariadb-docs
Provide additional documentation for SQLALCHEMY_POOL_RECYCLE
2 parents fa3f550 + ecc9498 commit eade982

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,4 @@ Patches and Suggestions
4848
- Steven Harms
4949
- David Lord @davidism
5050
- Alec Nikolas Reiter @justanr
51+
- Nick Whyte @nickw444

docs/config.rst

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ A list of configuration keys currently understood by the extension:
4747
connections after 8 hours idle by
4848
default. Note that Flask-SQLAlchemy
4949
automatically sets this to 2 hours if
50-
MySQL is used.
50+
MySQL is used. Some backends may use a
51+
different default timeout value. For more
52+
information about timeouts see
53+
:ref:`timeouts`.
5154
``SQLALCHEMY_MAX_OVERFLOW`` Controls the number of connections that
5255
can be created after the pool reached
5356
its maximum size. When those additional
@@ -144,3 +147,21 @@ example, as suggested by the SQLAlchemy docs::
144147
For more info about :class:`~sqlalchemy.schema.MetaData`,
145148
`check out the official docs on it
146149
<http://docs.sqlalchemy.org/en/latest/core/metadata.html>`_.
150+
151+
.. _timeouts:
152+
153+
Timeouts
154+
--------
155+
156+
Certain database backends may impose different inactive connection timeouts,
157+
which interferes with Flask-SQLAlchemy's connection pooling.
158+
159+
By default, MariaDB is configured to have a 600 second timeout. This often
160+
surfaces hard to debug, production environment only exceptions like ``2013: Lost connection to MySQL server during query``.
161+
162+
If you are using a backend (or a pre-configured database-as-a-service) with a
163+
lower connection timeout, it is recommended that you set
164+
`SQLALCHEMY_POOL_RECYCLE` to a value less than your backend's timeout.
165+
166+
167+

0 commit comments

Comments
 (0)