Skip to content

Commit 93805db

Browse files
authored
Improve transaction timeout docs (#966)
The timeout behaves differently on different server versions in respects to the user being or not being able to overwrite the server timeout with a bigger value. Also make sure the docs mention special values like `0`.
1 parent a2f35e1 commit 93805db

File tree

4 files changed

+62
-20
lines changed

4 files changed

+62
-20
lines changed

docs/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
Sphinx Documentation
33
====================
44

5+
Building the docs requires Python 3.8+
6+
57
In project root
68
```
79
pip install -r requirements-dev.txt

src/neo4j/_async/work/session.py

+12-4
Original file line numberDiff line numberDiff line change
@@ -452,10 +452,18 @@ async def begin_transaction(
452452
453453
:param timeout:
454454
the transaction timeout in seconds.
455-
Transactions that execute longer than the configured timeout will be terminated by the database.
456-
This functionality allows to limit query/transaction execution time.
457-
Specified timeout overrides the default timeout configured in the database using ``dbms.transaction.timeout`` setting.
458-
Value should not represent a duration of zero or negative duration.
455+
Transactions that execute longer than the configured timeout will
456+
be terminated by the database.
457+
This functionality allows to limit query/transaction execution
458+
time.
459+
The Specified timeout overrides the default timeout configured in
460+
the database using the ``db.transaction.timeout`` setting
461+
(``dbms.transaction.timeout`` before Neo4j 5.0).
462+
Values higher than ``db.transaction.timeout`` will be ignored and
463+
will fall back to the default for server versions 4.2 to including
464+
5.2. The value should not represent a negative duration.
465+
A ``0`` duration will make the transaction execute indefinitely.
466+
:data:`None` will use the default timeout configured on the server.
459467
460468
:returns: A new transaction instance.
461469

src/neo4j/_sync/work/session.py

+12-4
Original file line numberDiff line numberDiff line change
@@ -452,10 +452,18 @@ def begin_transaction(
452452
453453
:param timeout:
454454
the transaction timeout in seconds.
455-
Transactions that execute longer than the configured timeout will be terminated by the database.
456-
This functionality allows to limit query/transaction execution time.
457-
Specified timeout overrides the default timeout configured in the database using ``dbms.transaction.timeout`` setting.
458-
Value should not represent a duration of zero or negative duration.
455+
Transactions that execute longer than the configured timeout will
456+
be terminated by the database.
457+
This functionality allows to limit query/transaction execution
458+
time.
459+
The Specified timeout overrides the default timeout configured in
460+
the database using the ``db.transaction.timeout`` setting
461+
(``dbms.transaction.timeout`` before Neo4j 5.0).
462+
Values higher than ``db.transaction.timeout`` will be ignored and
463+
will fall back to the default for server versions 4.2 to including
464+
5.2. The value should not represent a negative duration.
465+
A ``0`` duration will make the transaction execute indefinitely.
466+
:data:`None` will use the default timeout configured on the server.
459467
460468
:returns: A new transaction instance.
461469

src/neo4j/_work/query.py

+36-12
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,31 @@ class Query:
3636
3737
:param text: The query text.
3838
:type text: typing.LiteralString
39-
:param metadata: metadata attached to the query.
39+
:param metadata:
40+
a dictionary with metadata.
41+
Specified metadata will be attached to the executing transaction
42+
and visible in the output of ``SHOW TRANSACTIONS YIELD *``
43+
It will also get logged to the ``query.log``.
44+
This functionality makes it easier to tag transactions and is
45+
equivalent to the ``dbms.setTXMetaData`` procedure, see
46+
https://neo4j.com/docs/cypher-manual/current/clauses/transaction-clauses/#query-listing-transactions
47+
and https://neo4j.com/docs/operations-manual/current/reference/procedures/
48+
for reference.
4049
:type metadata: typing.Dict[str, typing.Any] | None
41-
:param timeout: seconds.
50+
:param timeout:
51+
the transaction timeout in seconds.
52+
Transactions that execute longer than the configured timeout will
53+
be terminated by the database.
54+
This functionality allows to limit query/transaction execution
55+
time.
56+
The Specified timeout overrides the default timeout configured in
57+
the database using the ``db.transaction.timeout`` setting
58+
(``dbms.transaction.timeout`` before Neo4j 5.0).
59+
Values higher than ``db.transaction.timeout`` will be ignored and
60+
will fall back to the default for server versions 4.2 to including
61+
5.2. The value should not represent a negative duration.
62+
A ``0`` duration will make the transaction execute indefinitely.
63+
:data:`None` will use the default timeout configured on the server.
4264
:type timeout: float | None
4365
"""
4466
def __init__(
@@ -90,16 +112,18 @@ def count_people_tx(tx):
90112
91113
:param timeout:
92114
the transaction timeout in seconds.
93-
Transactions that execute longer than the configured timeout will be
94-
terminated by the database.
95-
This functionality allows to limit query/transaction execution time.
96-
Specified timeout overrides the default timeout configured in the
97-
database using ``dbms.transaction.timeout`` setting.
98-
Values higher than ``dbms.transaction.timeout`` will be ignored and
99-
will fall back to default (unless using Neo4j < 4.2).
100-
Value should not represent a negative duration.
101-
A zero duration will make the transaction execute indefinitely.
102-
None will use the default timeout configured in the database.
115+
Transactions that execute longer than the configured timeout will
116+
be terminated by the database.
117+
This functionality allows to limit query/transaction execution
118+
time.
119+
The Specified timeout overrides the default timeout configured in
120+
the database using the ``db.transaction.timeout`` setting
121+
(``dbms.transaction.timeout`` before Neo4j 5.0).
122+
Values higher than ``db.transaction.timeout`` will be ignored and
123+
will fall back to the default for server versions 4.2 to including
124+
5.2. The value should not represent a negative duration.
125+
A ``0`` duration will make the transaction execute indefinitely.
126+
:data:`None` will use the default timeout configured on the server.
103127
:type timeout: float | None
104128
105129
:rtype: typing.Callable[[T], T]

0 commit comments

Comments
 (0)