Skip to content

Error when double committing or rollbacking a transaction

Sami Hiltunen requested to merge smh-error-dbl-commit-rollbak into master

Transaction currently doesn't check whether it has already had Commit() or Rollback() called on it when either is called. This currently leads to failures and unexpected behavior. While there are currently no callers doing so, this will be a common pattern as we start integrating the transactions in the RPC handlers. They'll generally defer a rollback immediately after beginning a transaction and commit the transaction at the end of the RPC if is successful. The common sequence is thus calling commit, followed by the deferred rollback call.

This commit changes Commit() and Rollback() to return an appropriate error if the transaction is already committed or rollbacked. The caller can then handle the error if it doesn't care about it. There will be a helper later to handle logging rollback errors. That logging helper will ignore the 'already committed' errors given they are expected but not other errors.

Merge request reports