cockroach-go icon indicating copy to clipboard operation
cockroach-go copied to clipboard

should be able to `return tx.Commit()` from closure?

Open tbg opened this issue 8 years ago • 2 comments

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)
        }

tbg avatar Jul 20 '16 12:07 tbg

Looks like a wontfix? https://github.com/cockroachdb/cockroach-go/blob/6fd53f6d2eea06acb0c7f7aa88e0547acb32441b/crdb/tx.go#L74

tamird avatar Apr 25 '17 22:04 tamird

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?

andreimatei avatar Jul 01 '17 04:07 andreimatei