trinodb / trino

Official repository of Trino, the distributed SQL query engine for big data, formerly known as PrestoSQL (https://trino.io)
https://trino.io
Apache License 2.0
10.27k stars 2.95k forks source link

Trino JDBC driver not aborting on expired transactions #8322

Open davidkl97 opened 3 years ago

davidkl97 commented 3 years ago

Hey , I'm using the JDBC driver(358 version) bundled in Kafka connect and running scheduled queries again the trino server(358 version). At rare occasions, i could experience external failures in the queries im executing(might be a network issue or connector issue) which aborts the transaction at the server side but not in the client side. instead of trying to make a new transaction, the jdbc driver reflects the connection is valid but tries to use the expired transaction id.

i would expect a reflection of this failure on the client side also which could trigger to close connection or to restart a new transaction.

Any help would be appreciated :)

Thanks

electrum commented 3 years ago

Your application is probably disabling auto-commit by calling connection.setAutoCommit(false). If using auto-commit, the client will create a new transaction for each query. In transaction mode, the application needs to call connection.rollback() after a failure. However, it appears that rollback() should clear the transaction ID after executing ROLLBACK on the server side (regardless of whether that commands succeeds), which is likely the issue you are seeing.