neo4j / neo4j-python-driver

Neo4j Bolt driver for Python
https://neo4j.com/docs/api/python-driver/current/
Other
883 stars 187 forks source link

[4.4] Fix handling of sub-ms transaction timeouts #1034

Closed robsdedude closed 3 months ago

robsdedude commented 3 months ago

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: https://github.com/neo4j/neo4j-python-driver/pull/940