Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add warnings and recommendations to docs about timeout-related connection leaks #729

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/api/baseplate/clients/sqlalchemy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ request::
Configuration
-------------

.. warning::

:py:class:`sqlalchemy.pool.QueuePool` does not handle `ServerTimeout`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a code example of how to do this the right way vs wrong way? That'd be great to include here

(generally I prefer it when saying "Don't do it this way" to guide people through the right way of doing it (though the starting pointers of "do this instead" helps a lot))

exceptions gracefully, potentially leaking connections. It is recommended
to avoid local pooling entirely (via :py:class:`sqlalchemy.pool.NullPool`)
while this issue persists and instead rely on middleware pooling (such as
`pgbouncer`).

.. autoclass:: SQLAlchemySession

.. autofunction:: engine_from_config
Expand Down
8 changes: 8 additions & 0 deletions docs/api/baseplate/observers/timeout.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ upstream services are yet taken into account.
taking a long time because it is doing compute-heavy actions and not
yielding to the event loop it might go on longer than the allotted timeout.

.. warning::

The timeout mechanism may throw a `ServerTimeout` exception whenever a gevent
context switch occurs. If this exception is not handled gracefully your
application could get stuck in a bad state. For example, if a `ServerTimeout`
exception is thrown while releasing a connection then the connection might
never be fully released.

.. versionadded:: 1.2

.. versionchanged:: 1.3.3
Expand Down