On 24 November 2017 at 16:44, Jiří Matějka <mate...@emclient.com> wrote:
> We need to lock our SQLite datafiles at the filesystem level, because our > application frequently crashes with "database is locked" error, which is > probably due to other processes opening our files. At least we identified > Windows Search indexing service and McAffee antivirus. > sqlite does try to work around this kind of interference (see winLock() "Try 3 times to get the pending lock" and winRetryIoerr() used all over the place) > I have tried exclusive locking mode by > PRAGMA locking_mode=EXCLUSIVE; > but this does not prevent reading and modifying the file from other > processes while they are open by SQLite in our process. > Right, but it should still prevent OS level "database is locked" errors by virtue of the fact that SQLite no longer relinquishes its locks in this mode. So it will only call LockFile/LockFileEx a handful of times before escalating to the highest possible lock (which _will_ prevent other SQLite instances from operating on the database until your process closes it). Do you have more than one connection to the database? Is this error coming from sqlite3_close? Are you in WAL mode? These introduce other opportunities for "database is locked" which have nothing to do with the operating environment. -Rowan _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users