Hi all,

        To prevent race conditions where a 2nd process accesses a newly-created 
SQLite file before the creator process can set up the schema, I?ve 
implemented logic like this:

- create SQLite file as a .tmp beside permanent location

- BEGIN EXCLUSIVE LOCK

- hard-link the temp file to the permanent location

- create schema

- COMMIT

- unlink temp file

        This prevents the problem because the permanent file never exists 
unlocked prior to the schema existence. The 2nd process would either 
fail to open the DB because it?s locked or open it and see the schema.

        I?m seeing some corruption in our SQLite files now but have had a hard 
time tracking down the cause. Could it be because of the above logic? 
What have folks here done to avoid the race condition originally 
described? I?ve seen some documentation of SQLite and hard links but

-FG

Reply via email to