[4.4] Fix handling of sub-ms transaction timeouts#1034
Merged
robsdedude merged 5 commits intoneo4j:4.4from Apr 11, 2024
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.
Back-port of: neo4j#940
AndyHeap-NeoTech
approved these changes
Apr 4, 2024
Contributor
AndyHeap-NeoTech
left a comment
There was a problem hiding this comment.
Just one question. Looks good though.
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.
Back-port of: #940