Fix handling of sub-ms transaction timeouts#940
Merged
robsdedude merged 2 commits intoneo4j:5.0from Jun 30, 2023
Merged
Conversation
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.
bigmontz
approved these changes
Jun 28, 2023
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Transaction timeouts are specified in seconds as float. However, the server expects it in milliseconds as int. This would lead to
then truncate to int. E.g., 256.4 seconds would be turned into 256399 ms
because of float imprecision.
Therefore, the built-in
roundis now used instead.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.