Skip to content

Fix handling of sub-ms transaction timeouts #940

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
Jun 30, 2023

Conversation

robsdedude
Copy link
Member

Transaction timeouts are specified in seconds as float. However, the server expects it in milliseconds as int. This would lead to

  1. rounding issues: previously, the driver would multiply by 1000 and
    then truncate to int. E.g., 256.4 seconds would be turned into 256399 ms
    because of float imprecision.
    Therefore, the built-in round is now used instead.
  2. values below 1 ms (e.g., 0.0001) would be rounded down to 0. However, 0 is
    a special value that instructs the server to not apply any timeout. This
    is likely to surprise the user which specified a non-zero timeout. In this
    special case, the driver now rounds up to 1 ms.

Transaction timeouts are specified in seconds as float.
However, the server expects it in milliseconds as int.
This would lead to
 1) rounding issues: previously, the driver would multiply by 1000 and
    then truncate to int. E.g., 256.4 seconds would be turned into 256399 ms
    because of float imprecision.
    Therefore, the built-in `round` is now used instead.
 2) values below 1 ms (e.g., 0.0001) would be rounded down to 0. However, 0 is
    a special value that instructs the server to not apply any timeout. This
    is likely to surprise the user which specified a non-zero timeout. In this
    special case, the driver now rounds up to 1 ms.
Copy link
Contributor

@bigmontz bigmontz left a comment

Choose a reason for hiding this comment

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

👻

@robsdedude robsdedude merged commit 8d7b04a into neo4j:5.0 Jun 30, 2023
@robsdedude robsdedude deleted the fix-tx-timeout-rounding branch June 30, 2023 09:57
robsdedude added a commit to robsdedude/neo4j-python-driver that referenced this pull request Apr 2, 2024
Transaction timeouts are specified in seconds as float.
However, the server expects it in milliseconds as int. This would lead to

 1) rounding issues: previously, the driver would multiply by 1000 and
    then truncate to int. E.g., 256.4 seconds would be turned into 256399 ms
    because of float imprecision.
    Therefore, the built-in `round` is now used instead.
 2) values below 1 ms (e.g., 0.0001) would be rounded down to 0. However, 0 is
    a special value that instructs the server to not apply any timeout. This
    is likely to surprise the user which specified a non-zero timeout. In this
    special case, the driver now rounds up to 1 ms.

Back-port of: neo4j#940
robsdedude added a commit that referenced this pull request Apr 11, 2024
Transaction timeouts are specified in seconds as float.
However, the server expects it in milliseconds as int. This would lead to

 1) rounding issues: previously, the driver would multiply by 1000 and
    then truncate to int. E.g., 256.4 seconds would be turned into 256399 ms
    because of float imprecision.
    Therefore, the built-in `round` is now used instead.
 2) values below 1 ms (e.g., 0.0001) would be rounded down to 0. However, 0 is
    a special value that instructs the server to not apply any timeout. This
    is likely to surprise the user which specified a non-zero timeout. In this
    special case, the driver now rounds up to 1 ms.

Backport of: #940

Backport adjustment:
For better backwards compatibility, we're sending negative timeouts to the
DBMS as the 4.4 driver did before (even though those values might not have the
intuitive effect, we don't want to change the behavior of the driver too much in
a patch release).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants