You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Tx is an in-progress database transaction.
A transaction must end with a call to Commit or Rollback.
After a call to Commit or Rollback, all operations on the transaction fail with ErrTxDone.
The statements prepared for a transaction by calling the transaction's Prepare or Stmt methods are closed by the call to Commit or Rollback.
The documentation should clarify if that is only the case if Commit or Rollback return a nil error.
What happens if they return a non-nil error? Should we try and call Commit or Rollback again? Will other operations still return ErrTxDone?
The text was updated successfully, but these errors were encountered:
I think that depends on the error it returns. What you are asking is undefined at this level. Maybe the Tx Commit failed because of a temporary network condition. But the safest way is to assume a rollback on error.
In most cases on the server, an open Tx on the DB Server (as far as I understand) will rollback the Tx (eventually). But even this may depend on the exact settings of the system and session. So to answer your question about what you should do? Assume the Commit (or rollback) will (evetually) result in a rollback (depending your server db and db and session settings) and rely the failure without an immediate retry of said operation.
That being said, We don't have a great state chart of what could go wrong, nor do we have a list documentation from various vendors on how their systems handle transaction failures, and what their failure modes are.
As a counter-point to the above, if you are running something like cockroachdb, it may fail with a specific error message that says "please retry, your tx was rolledbacked due to another tx activity".
The docs state:
The documentation should clarify if that is only the case if Commit or Rollback return a nil error.
What happens if they return a non-nil error? Should we try and call Commit or Rollback again? Will other operations still return ErrTxDone?
The text was updated successfully, but these errors were encountered: