The return status is not checked in the code I pasted to avoid cluttering the code, which is just an example to show the issue. This is not real-world code. The sleeps here are enough to reproduce the issue in any reasonable system, they are meant to simplify the example code. Checking the return code or using safe synchronization primitives won't change the point I'm trying to make. The fact that sqlite3_step() is not called in "SELECT * FROM sqlite_master" is by purpose, not neglected. Preparing the statement is sufficient to initialize the internal schema cache of that connection, which is all what is needed to highlight the issue here.