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
I'm guessing you have another test case that inserts a user into a database returned by getTestDatabase, but neglects to defer db.Close() (or use t.Cleanup). Consequently, you may observe such side effects. See for reference https://www.sqlite.org/draft/inmemorydb.html
The database is automatically deleted and memory is reclaimed when the last connection to the database closes.
So I looked into it some more and I think what was happening was the database was being closed, but this was being handled in a go-routine listener thread. The race condition on my end was for the go-routine to notice and shut down the database connections before the test framework moved on to the next test.
I corrected this by making the defer'd shutdown function block until all the parts are properly shutdown. So I guess I was holding it wrong.
Unsure if this case should be documented so leaving it open for now, but if you don't feel that's necessary feel free to close. Thanks!
Just to check my prerequisites, I've already read through #1205 and the faq so I'm pretty sure I'm holding it right. :-D
Currently using mattn/go-sqlite3 v1.14.22 on go1.22.1 windows/amd64. Running on Windows 10 x64. GCC is
gcc version 10.3.0 (tdm64-1)
.Code
My unit tests call the following function at the beginning:
Test output:
The errors are very inconsistent: rerunning the test framework (
go test ./... -count=5
), tests will often pass or fail pretty randomly.Some connection strings I have tried:
What does seem to work:
Any of the above memory options, but setting the filename to a unique string for the given test. Notice below that I'm not even using
cache=shared
:Posting this here to continue the discussion and hopefully help anyone else who gets caught with this error.
(Thank you for the awesome library, btw! Greatly enjoying learning go with it.)
The text was updated successfully, but these errors were encountered: