On Fri, 24 Sep 2004, Eddy Macnaghten wrote:
There is no way I can guarantee the "nfs" to be good. Also, a mixture of Linux and Windows clients need to be allowed for, I do not know how SAMBA supports the fcntl functionality, or how well it interfaces with the Windows Server or Client locking mechanisms.
why not a simple lock daemon then?
Hmm - interesting. However, I cannot really use your method as link(2) is not really available under Windows (as far as I can tell).
The mechanism I use is not brilliant, that is that it does not guarantee 100% that locking is successful! - Though I have taken care to make sure it is as close to 99.999 (as many 9s as possible) % sure that it is.
The more clients there is the more likely it is to fail, which is why this is only good for a small number of clients (approx 5) in non mission-critical applications. I do not know how easy it is to recover a corrupt sqlite3 database file, if there is not a utility to do that then I will probably work on one (it would open the file exclusively and create a dump that can be re-imported into a new database).
My lock file has a 16 byte header, then a number of 4 byte records each representing a lock aquired by someone. Each client has a unique number. When a lock is to be aquired the cliet first checks to see if the file is free (the first byte is zero), if it is not it waits 1/100 of a second and tries again. If it is free it sets the first byte to -1, and the appropriate header field to the client number. It then reads the header (with the first 512 bytes) again and checks that it still "owns" the file (the appropriate header field set to the client number) - if not starts the process again - if it does it then performs searches and updates on the file accordingly, unowning the file (setting the first bu=yte to zero) when finished.
I will post the source on my web site soon if you are interested.
it's interesting even if it contains many race conditions due to inode caching - i'd like to see it though.
This is essential in my case IMHO. I suppose in theory this could be an atrribute of the connection API call, but it does not belong there. If some clients use one kind of locking mechanism, and others use another, database corruption and problems are guaranteed!
agreed.
cheers.
-a
--
===============================================================================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| A flower falls, even though we love it;
| and a weed grows, even though we do not love it. | --Dogen
===============================================================================