Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix "cannot start a transaction within a transaction" issue
[why] If db.BeginTx(ctx, nil) context is cancelled too fast, "BEGIN" statement can be completed inside DB, but we still try to cancel it with sqlite3_interrupt. In such case we get context.Cancelled or context.DeadlineExceeded from exec(), but operation really completed. Connection returned into pool, and returns "cannot start a transaction within a transaction" error for next db.BeginTx() call. [how] If we get context cancelled on "BEGIN" statement, call "ROLLBACK" to clean-up connection state. Don't return cancellation error from exec() if operation completed without sqlite3_interrupt. [testing] Added unit-test which reproduces issue.
- Loading branch information
1 parent
590d44c
commit f9c4758
Showing
2 changed files
with
51 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters