Skip to content

Commit 164fbed

Browse files
committed
Warn about using schema-scoped connections with transaction pooler
1 parent a792706 commit 164fbed

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

docs/source/schemas.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,6 @@ Without an outer transaction, the temporary schema might not be dropped when you
9898
9999
By default, the drop will fail if the schema is not empty or there is anything referencing the schema. Specify ``cascade=True`` to drop all of the schema's contents and **anything referencing it**.
100100
101-
.. note::
102-
103-
104101
.. code-block:: python
105102
106103
for psqlextra.schema import postgres_temporary_schema
@@ -151,7 +148,11 @@ By default, a connection operates in the ``public`` schema. The schema offers a
151148
152149
.. warning::
153150
154-
Do not pass the connection to a different thread. It is **NOT** thread safe.
151+
Do not use this in the following scenarios:
152+
153+
1. You access the connection from multiple threads. Scoped connections are **NOT** thread safe.
154+
155+
2. The underlying database connection is passed through a connection pooler in transaction pooling mode.
155156
156157
.. code-block:: python
157158

psqlextra/schema.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,15 @@ def delete(self, *, cascade: bool = False) -> None:
165165

166166
@property
167167
def connection(self) -> BaseDatabaseWrapper:
168-
"""Obtains a database connection scoped to this schema."""
168+
"""Obtains a database connection scoped to this schema.
169+
170+
Do not use this in the following scenarios:
171+
172+
1. You access the connection from multiple threads. Scoped
173+
connections are NOT thread safe.
174+
2. The underlying database connection is passed through a
175+
connection pooler in transaction pooling mode.
176+
"""
169177

170178
return PostgresSchemaConnectionWrapper(connections[self.using], self)
171179

0 commit comments

Comments
 (0)