Hi there, We use SQLite in our application to store the data, and some of our users prefer to keep the files on a network drive. The application opens a connection to sqlite database and keeps it open for a while, storing and retrieving the data at user's request.
The issue that some clients have reported is that if a network error occurs (they have really dodgy network), the application reports that the database is locked. I investigated the problem and it looks file if database file handle becomes invalid, SQLite reports that the database is locked for any sql statement. Therefore there is no reliable way at the moment to distinguish if the database is locked by someone else on the network or the network connection was dropped/interrupted and the database file needs to be reopen. To illustrate the problem, start sqlite shell for some existing sqlite database, start Process Explorer (http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx), locate sqlite shell process and close the handle for database file. Now try any sql statement - the error message you get is "Database is locked" which is confusing and incorrect. The problem goes down to winLock() implementation, particularly to winLockFile() (WIN32 LockFileEx())call. The logic is that if winLockFile() fails, the file is considered locked which is not true for this particular case. Actually if file handle is no longer valid, GetLastError() returns ERROR_INVALID_HANDLE rather than ERROR_LOCK_FAILED and retrying after a timeout won't resolve the issue. Maybe this bit of code needs to be reviewed to return appropriate status, even though this condition is unlikely to happen for the majority of the users. Regards, Denis [Micromine PL]
_______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users