23 Jan 03:27
Re: Database Locking
Jeff Stearns <jeff.stearns+gmane <at> gmail.com>
2010-01-23 02:27:42 GMT
2010-01-23 02:27:42 GMT
Olly Betts <olly <at> survex.com> writes: > Locking of Quartz databases is currently done with a lockfile. This > works well from the actual locking side, but the downside is that > the lock isn't released if a process doesn't destroy the > Xapian::WritableDatabase object. This is made worse because some > of the bindings don't call destructors (or don't do it reliably). > > The obvious alternative is to use actual locking APIs. On Unix, this > mean fcntl. Windows has a suitable API too. > > But the problem is that on Unix, fcntl locks are per process. So if > we used fcntl locking, then if a process tried to open the same database > twice as a WritableDatabase, it would succeed. This is probably more of > a worry in a threaded application, but threads aren't actually needed to > hit this problem. Olly - I know nothing about the internals of Xapian, but I wonder whether this cunning plan is more complex and expensive than necessary. I wonder why Xapian doesn't apply the flock, then set a flag indicating that the database is locked. Now whenever Xapian goes to open a database, it would first check whether the flag is set. If so, Xapian knows that that the database is already open within this process. If the flag is not set, Xapian continues onward, probing the file with flock to see whether it's open within some other process. This should work in a threaded environment so long as the customary(Continue reading)
RSS Feed