-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error "cannot start a transaction within a transaction" on cached connection #764
Comments
@azavorotnii If I understand your bug report correctly, this is not a bug with Lines 1893 to 1905 in 590d44c
The existing code erroneously concludes that if we called I believe the correct fix would be to not just discard what gets pulled from I have also sent a question to the SQLite mailing list about the behavior when ETA: The SQLite maintainers say that if you interrupt a call to |
@rittneje that was my initial thought, but for some reason instead of SQLITE_INTERRUPT I got SQLITE_DONE. That could be race in my test setup though (not same test as in this PR). Let me check again. |
@rittneje done as you proposed. I did mistake in my initial test, now it should be stable. |
…1363) * Add some error wrapping to sync API * Don't use request context for BeginTx until mattn/go-sqlite3#764 is fixed
) * 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] Handle status code returned from cancelled operation. [testing] Added unit-test which reproduces issue. * Reduce TestQueryRowContextCancelParallel concurrency [why] Tests times out in travis-ci when run with -race option.
…atrix-org#1363) * Add some error wrapping to sync API * Don't use request context for BeginTx until mattn/go-sqlite3#764 is fixed
Assuming we run this piece of code:
it is possible to get at the same time context.Cancelled error and started transaction. This will happen only if we cancel context very fast.
This happens because context cancellation is inherently racy as performed not in same go-routine where statement is executed.
Proposed fix #765
The text was updated successfully, but these errors were encountered: