cockroach-go
cockroach-go copied to clipboard
should be able to `return tx.Commit()` from closure?
sql: Transaction has already been committed or rolled back
if err := crdb.ExecuteTx(client.DB, func(tx *sql.Tx) error {
// do stuff
return tx.Commit() // works when returning `nil`
}); err != nil {
t.Fatalf("%+v", err)
}
Looks like a wontfix? https://github.com/cockroachdb/cockroach-go/blob/6fd53f6d2eea06acb0c7f7aa88e0547acb32441b/crdb/tx.go#L74
Yeah... What's the suggestion here, Tobi? Even without the fact that you can't react to a retryable error after you attempt a commit
, how would ExecuteTx()
know if it's supposed to attempt to commit or if the closure did it?