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).
Dear Charles,
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
Hi Charles,
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
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.
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
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 ___________________________
On Sat, Mar 17, 2012 at 10:59 PM, Charles Duffy charles@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@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
basex-talk@mailman.uni-konstanz.de