SQLite Forum

'No such table' returned while the database contains it
Login
Hi,

I'm hitting an issue in my application, which basically sums up to the first request executed by a thread failing with 'No such table', while the table definitely exists in the database. It seems the connection refers to an empty database, but I can see content when browsing the database after the application crashed.

I can only reproduce this by running the same test a few times (sometimes the first one is enough) on a rather powerful machine that's usually used for our CI. Not sure if that has to do with its speed or if it's related to CPU features. For what it's worth, I ran all tests in a docker image (and can't do otherwise on that machine)

Since I'm really not sure what to look for, here's what I tried:

In order to ensure the database isn't recreated for some reasons I explicitly pass the SQLITE_OPEN_CREATE flag to the first connection, and stick to SQLITE_OPEN_READWRITE for later ones. The failing connection is never the first one, only later ones from a different thread.

I usually keep a per-thread cache of prepared requests and reuse those, but disabling this doesn't change the outcome.

Synchronization between threads is handled by the application, and tsan doesn't appear to complain. Each thread has it's own connection to the database, and write requests are executed with an exclusive lock while read requests can be processed in parallel. However even if all requests are executed with an exclusive lock, the problem still occur.

I tried rebuilding sqlite with assertions, but nothing specific to report, but the crash still happens. Same results with tsan enabled for sqlite and my application, no report of anything.

I've been able to reproduce this with sqlite 3.25.3 (manually build), today's snapshot (202007031232) and 3.32.3-1 (packaged by debian)

I'm not really sure what to do/test from here, so any help would be highly appreciated! 

Thanks a lot in advance,