database/sql: Documentation clarification regarding Tx #28474
Comments
CC @kardianos |
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: