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
What steps reproduce the problem?
If possible, include a link to a program on play.golang.org.
1. Using the sqlite driver, start a long running query.
2. Attempt to insert a row into the same table you queried.
3. Attempt to commit the insert transaction. The commit will fail because of a lock on
the table.
This is fine except that the transaction commit function in database/sql closes the
database/sql transaction through the use of defer tx.close() even if the commit was
unsuccessful. I have not been able to regain control of this transaction once the
database/sql representation has closed.
What should have happened instead?
The database/sql transaction commit function should first attempt to commit the driver
transaction, and only if it has succeeded, close the database/sql representation.
The function in question:
1058 // Commit commits the transaction.
1059 func (tx *Tx) Commit() error {
1060 if tx.done {
1061 return ErrTxDone
1062 }
1063 defer tx.close()
1064 tx.dc.Lock()
1065 defer tx.dc.Unlock()
1066 return tx.txi.Commit()
1067 }