Commit Graph

21 Commits

Author SHA1 Message Date
Yasuhiro Matsumoto 1f0dc0a0ef go fmt ./... 2024-01-25 22:55:22 +09:00
Evan Jones 3fb3c0de37
TestExecContextCancel: Reduce timeout to make less flaky (#879)
This test fails fairly often. On my system, I can trigger it with:

    go test . -run=TestExecContextCancel -count=10 -failfast -v

This makes the test less flaky by timing out the context after a
consistent 50 millisecond delay. This was enough time for the query
to start, then get cancelled with sqlite3_interrupt() in my tests.
This now passes the above check.

This is a modified version of the change suggested in:
https://github.com/mattn/go-sqlite3/pull/865
2020-11-17 01:52:56 +09:00
Andrii Zavorotnii 862b95943f
Fix "cannot start a transaction within a transaction" issue (#764) (#765)
* 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.
2020-08-29 00:43:21 +09:00
mattn 590d44c02b
Merge pull request #744 from azavorotnii/ctx_cancel
Fix context cancellation racy handling
2019-11-19 01:19:53 +09:00
Yasuhiro Matsumoto fc06e55305
Add build constraints for non cgo 2019-11-18 18:03:31 +09:00
Andrii Zavorotnii 7e1a61dbcd Fix context cancellation racy handling
[why]
Context cancellation goroutine is not in sync with Next() method lifetime.
It leads to sql.ErrNoRows instead of context.Canceled often (easy to reproduce).
It leads to interruption of next query executed on same connection (harder to reproduce).

[how]
Do query in goroutine, wait when interruption done.

[testing]
Add unit test that reproduces error cases.
2019-09-06 12:15:53 -07:00
MichaelS11 57484d0899 Updated Ping to return ErrBadConn
Added TestOpenContext
Added TestFileCopyTruncate
Added ping to doTestOpen
2019-06-19 16:50:49 -07:00
Gert-Jan Timmer 668824341d Add Tests for Crypt Encoders
* Increase coverage
2018-06-12 13:57:14 +02:00
Niklas Janlert 58004848f1 Fix race in ExecContext
When the context is cancelled, an interrupt should only be made if the
operation is still ongoing.
2017-11-21 13:40:00 +01:00
Yasuhiro Matsumoto 5160b48509 fix test 2017-09-28 13:00:20 +09:00
Yasuhiro Matsumoto 103e6ee9ee remove rows.Close() in TestShortTimeout
couldn't reproduce on local environment
2017-09-28 12:56:17 +09:00
Yasuhiro Matsumoto c0f3d4135e fix broken test 2017-09-28 12:47:35 +09:00
Yasuhiro Matsumoto 49f9543f14 fix error handling
close #464
2017-09-28 12:40:27 +09:00
Yasuhiro Matsumoto 68bcba68d9 use file instead of memory for TestShortTimeout 2017-09-28 12:04:07 +09:00
Yasuhiro Matsumoto d40d490543 fixes #458 2017-08-28 18:58:02 +09:00
Yasuhiro Matsumoto 35cf400919 fix tests 2016-12-09 12:58:20 +09:00
Yasuhiro Matsumoto 8ecd77c707 fix test
see https://github.com/golang/go/issues/18099
2016-12-01 12:12:18 +09:00
Yasuhiro Matsumoto ea2afbe9e8 revert Multiple Result Set 2016-11-08 13:22:46 +09:00
Yasuhiro Matsumoto dd2c82226b fix trace callback.
Close #352
2016-11-08 12:19:51 +09:00
Yasuhiro Matsumoto 15491aeb9c go vet && golint 2016-11-06 13:16:38 +09:00
Yasuhiro Matsumoto 57eaf4c070 separate test 2016-11-04 15:17:21 +09:00