SQLite Forum

Opening a DB with SQLITE_OPEN_EXCLUSIVE
Login
Why are you checking if the database exists at all?  You do not care if the database exists or not.  You only care that you can open it.

You should be opening it and then checking to see if it contains what you expect it to contain, and if it does not, THEN you initialize the database.

If 700 copies of the application open the database at the SAME TIME, then all of them may notice (by testing) that the database does not contain anything (is empty) but ONLY ONE OF THEM will be able to begin a transaction to "initialize the database" and 699 of them will get SQLITE_BUSY when they try to start the transaction necessary to "initialize the database".

Where is the race condition?