vert-x3 / vertx-mysql-postgresql-client

This client is deprecated - use instead
https://github.com/eclipse-vertx/vertx-sql-client
Apache License 2.0
117 stars 59 forks source link

AsyncSQLConnectionImpl commits dirty data on close #155

Open jim-mclaugh opened 5 years ago

jim-mclaugh commented 5 years ago

It is possible for the AsyncSQLConnectionImpl class to commit dirty data on close. Most connection pool connection proxies detect if there are uncommitted statements (eg dirty state) when close is called on the connection and rollback those statements before returning the connection to the pool. AsyncSQLConnectionImpl takes the opposite approach and commits the dirty state before returning the connection to the pool.

In a reactive-streams context, a subscriber can abruptly dispose of a subscription without completion or error notifications occurring. To prevent resource leakage, such as database connection leaks, it is common to perform resource cleanup in doFinally since it will always be called when a stream is terminated whether that is due to completion, error, or disposal. If close is called in doFinally then a transaction might get committed even though not all the participating statements have executed.

To fix this, if dirty state is detected when close is called, rollback should be executed on the connection instead of commit