Detecting abandoned locks

Sunday, 18 March 2012 · 6 messages · last reply 9 Apr 2012
CD
Charles Duffy18 Mar 2012 00:05 #
Howdy -- I have a BaseX database with a pin-* file in its directory, reporting as locked and unavailable. However, OS-level tools such as fuser report that no programs have open file handles for any processes in this directory. What mechanism does BaseX use for detecting abandoned locks? It would be nice to use OS-level advisory locking where available, such that the lock is automatically released whenever the program holding it exits (or otherwise ceases to hold a handle on the file).
LW
Leonard Wörteler18 Mar 2012 09:42 #
Dear Charles,
Quoted text · Charles Duffy · 5 lines
Am 17.03.2012 22:59, schrieb Charles Duffy: > I have a BaseX database with a pin-* file in its directory, reporting as > locked and unavailable. However, OS-level tools such as fuser report > that no programs have open file handles for any processes in this > directory.
the pin file is created the moment between finishing an updating query and persisting the updates in the Pending Update List to the database. It is deleted when the database files have been successfully updated. If the pin file wasn't deleted, this is an indicator that a) there were read or write errors or b) the update operation was aborted, e.g. by Ctrl-C. So the database should be considered corrupted. Unfortunately there are no sophisticated recovery tools available for corrupted databases, but (assuming you don't have an up-to-date backup) you could try this: - (make a backup of the database folder) - delete the pin file, it's the only corruption marker - issue an OPTIMIZE ALL command on the database This tries to read the complete database into SAX-like events and build a new database from those. It should produce errors in most cases of corruption, but if it succeeds, you should still check manually. Hope this helps, cheers, Leo
CG
Christian Grünin reply to Charles Duffy, 18 Mar 2012, 00:0519 Mar 2012 00:59 #
Hi Charles,
Quoted text · Charles Duffy · 3 lines
> I have a BaseX database with a pin-* file in its directory, reporting as > locked and unavailable. However, OS-level tools such as fuser report that no > programs have open file handles for any processes in this directory.
pin files have been introduced just recently to avoid that databases are simultaneously updated by several clients, using several JVMs [1]. If a pin file remains in a database directory, it seems this database has not been properly closed. Currently, there is no mechanism yet to detect orphaned pin files, as the first tests I did with channel().lock() etc. haven't been that successful, or too slow. Christian [1] https://github.com/BaseXdb/basex/issues/168
CG
Christian Grünin reply to Charles Duffy, 20 Mar 2012, 18:5220 Mar 2012 18:34 #
Quoted text · Charles Duffy · 4 lines
> According to the docs, java.nio.channels.FileLock should be implemented on > UNIXlike operating systems with flock() or fcntl(), both of which are widely > used, fast and reliable. I don't know how the Windows version would be > implemented, but I'm quite curious about the result of your tests.
Thanks for the feedback. It may take same time until we'll find the time to look at this more closely.. Christian
CD
Charles Duffyin reply to Christian Grün, 19 Mar 2012, 00:5920 Mar 2012 18:52 #
Quoted text · Christian Grün · 4 lines
On 03/18/2012 06:59 PM, Christian Grün wrote: > Currently, there is no mechanism yet to detect orphaned pin files, as > the first tests I did with channel().lock() etc. haven't been that > successful, or too slow.
Hmm. According to the docs, java.nio.channels.FileLock should be implemented on UNIXlike operating systems with flock() or fcntl(), both of which are widely used, fast and reliable. I don't know how the Windows version would be implemented, but I'm quite curious about the result of your tests.
CG
Christian Grünin reply to Charles Duffy, 18 Mar 2012, 00:059 Apr 2012 19:25 #
Hi Charles, as recently discussed, we have replaced our pinning concept with shared & exclusive locks on the database table, which seems to work out pretty well. Your feedback is welcome, Thanks for your valuable input, Christian
Quoted text · Charles Duffy · 16 lines
On Sat, Mar 17, 2012 at 10:59 PM, Charles Duffy <charles at dyfis.net> wrote: > Howdy -- > > I have a BaseX database with a pin-* file in its directory, reporting as > locked and unavailable. However, OS-level tools such as fuser report that no > programs have open file handles for any processes in this directory. > > What mechanism does BaseX use for detecting abandoned locks? It would be > nice to use OS-level advisory locking where available, such that the lock is > automatically released whenever the program holding it exits (or otherwise > ceases to hold a handle on the file). > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk

⚡Generated with XQuery