Ensures cleanup of transactions that failed to commit is under a lock

Adds a synchronized block around commit and rollback in case of failure
 in TxManager. This ensures that a transaction has the chance to clean up
 its state atomically, preventing a class of errors encountered in HA settings.