Hi,
Am 30.03.2012 00:03, schrieb Dimitar Popov:
The PUT request waits, which is ok, but if the GET request is interrupted, the PUT receives:
"Database 'testdb' is currently opened by another client."
Subsequent attempts to execute the PUT request fail with the same error.
that seems to be the per-database pin file again that I mistook for the (similar, but distinct) write lock last time.
The current approach is simple and effective, but it doesn't work at all if the BaseX instance is terminated before it can delete the pin files. That's actually what we want for the write lock, because terminating the instance while it writes the updates to disk pretty much guarantees curruption, but it's too strict for marking opened databases.
My first idea would be to try and lock the main table of the database, `tbl.basex`, via FileChannel.tryLock(). That should be just as effective in preventing concurrent access, with the added benefit of leaving no orphaned files behind when the BaseX instance isn't terminated gracefully.
@Christian, could you elaborate on the outcome of the tests you did with file locks? I'll look into it, too.
Cheers, Leo
P.S.: You can render the database usable again by deleting the pin-* file by hand.