Skip to content

Improve transaction timeout docs #966

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

Merged
merged 2 commits into from
Sep 25, 2023
Merged
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
2 changes: 2 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
Sphinx Documentation
====================

Building the docs requires Python 3.8+

In project root
```
pip install -r requirements-dev.txt
Expand Down
16 changes: 12 additions & 4 deletions src/neo4j/_async/work/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,10 +452,18 @@ async def begin_transaction(

:param timeout:
the transaction timeout in seconds.
Transactions that execute longer than the configured timeout will be terminated by the database.
This functionality allows to limit query/transaction execution time.
Specified timeout overrides the default timeout configured in the database using ``dbms.transaction.timeout`` setting.
Value should not represent a duration of zero or negative duration.
Transactions that execute longer than the configured timeout will
be terminated by the database.
This functionality allows to limit query/transaction execution
time.
The Specified timeout overrides the default timeout configured in
the database using the ``db.transaction.timeout`` setting
(``dbms.transaction.timeout`` before Neo4j 5.0).
Values higher than ``db.transaction.timeout`` will be ignored and
will fall back to the default for server versions 4.2 to including
5.2. The value should not represent a negative duration.
A ``0`` duration will make the transaction execute indefinitely.
:data:`None` will use the default timeout configured on the server.

:returns: A new transaction instance.

Expand Down
16 changes: 12 additions & 4 deletions src/neo4j/_sync/work/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,10 +452,18 @@ def begin_transaction(

:param timeout:
the transaction timeout in seconds.
Transactions that execute longer than the configured timeout will be terminated by the database.
This functionality allows to limit query/transaction execution time.
Specified timeout overrides the default timeout configured in the database using ``dbms.transaction.timeout`` setting.
Value should not represent a duration of zero or negative duration.
Transactions that execute longer than the configured timeout will
be terminated by the database.
This functionality allows to limit query/transaction execution
time.
The Specified timeout overrides the default timeout configured in
the database using the ``db.transaction.timeout`` setting
(``dbms.transaction.timeout`` before Neo4j 5.0).
Values higher than ``db.transaction.timeout`` will be ignored and
will fall back to the default for server versions 4.2 to including
5.2. The value should not represent a negative duration.
A ``0`` duration will make the transaction execute indefinitely.
:data:`None` will use the default timeout configured on the server.

:returns: A new transaction instance.

Expand Down
48 changes: 36 additions & 12 deletions src/neo4j/_work/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,31 @@ class Query:

:param text: The query text.
:type text: typing.LiteralString
:param metadata: metadata attached to the query.
:param metadata:
a dictionary with metadata.
Specified metadata will be attached to the executing transaction
and visible in the output of ``SHOW TRANSACTIONS YIELD *``
It will also get logged to the ``query.log``.
This functionality makes it easier to tag transactions and is
equivalent to the ``dbms.setTXMetaData`` procedure, see
https://neo4j.com/docs/cypher-manual/current/clauses/transaction-clauses/#query-listing-transactions
and https://neo4j.com/docs/operations-manual/current/reference/procedures/
for reference.
:type metadata: typing.Dict[str, typing.Any] | None
:param timeout: seconds.
:param timeout:
the transaction timeout in seconds.
Transactions that execute longer than the configured timeout will
be terminated by the database.
This functionality allows to limit query/transaction execution
time.
The Specified timeout overrides the default timeout configured in
the database using the ``db.transaction.timeout`` setting
(``dbms.transaction.timeout`` before Neo4j 5.0).
Values higher than ``db.transaction.timeout`` will be ignored and
will fall back to the default for server versions 4.2 to including
5.2. The value should not represent a negative duration.
A ``0`` duration will make the transaction execute indefinitely.
:data:`None` will use the default timeout configured on the server.
:type timeout: float | None
"""
def __init__(
Expand Down Expand Up @@ -90,16 +112,18 @@ def count_people_tx(tx):

:param timeout:
the transaction timeout in seconds.
Transactions that execute longer than the configured timeout will be
terminated by the database.
This functionality allows to limit query/transaction execution time.
Specified timeout overrides the default timeout configured in the
database using ``dbms.transaction.timeout`` setting.
Values higher than ``dbms.transaction.timeout`` will be ignored and
will fall back to default (unless using Neo4j < 4.2).
Value should not represent a negative duration.
A zero duration will make the transaction execute indefinitely.
None will use the default timeout configured in the database.
Transactions that execute longer than the configured timeout will
be terminated by the database.
This functionality allows to limit query/transaction execution
time.
The Specified timeout overrides the default timeout configured in
the database using the ``db.transaction.timeout`` setting
(``dbms.transaction.timeout`` before Neo4j 5.0).
Values higher than ``db.transaction.timeout`` will be ignored and
will fall back to the default for server versions 4.2 to including
5.2. The value should not represent a negative duration.
A ``0`` duration will make the transaction execute indefinitely.
:data:`None` will use the default timeout configured on the server.
:type timeout: float | None

:rtype: typing.Callable[[T], T]
Expand Down