OSDN Git Service

Fix handling of H2 lock files
authorNick Clarke <memorius@gmail.com>
Wed, 21 Jul 2010 02:35:23 +0000 (14:35 +1200)
committerRandy Baumgarte <randy@fbn.cx>
Fri, 23 Jul 2010 09:31:06 +0000 (05:31 -0400)
commit5d937f90329f96cafeb29d38e17dd857af46b3e5
treea5aafec24c71f71e080d7c9f0c534326cdca8a9d
parentf179b0318e61a0cf12b1806a345eb409cb913ee2
Fix handling of H2 lock files

We don't necessarily need to abort if an H2 db lock file exists.
H2 manages these lock files on its own, they should never need manual deleting;
see here for details:
http://www.h2database.com/html/advanced.html#file_locking_protocols

If the lock file exists and another process has the DB open,
H2 will automatically detect this and will throw an exception when trying to
open the DB. I've restructured some startup code to detect this and
cleanly abort NeverNote startup before we do anything dangerous like deleting
files from the 'res' dir. The correct resolution is to close or kill the other
NeverNote process, no need to do anything to the lock file.

If the lock file exists but no other process has the DB open, as happens if
NeverNote crashes badly e.g. due to a segfault in QTJambi, then H2 will also
detect this and will allow startup to proceed anyway.
src/cx/fbn/nevernote/NeverNote.java
src/cx/fbn/nevernote/config/FileManager.java
src/cx/fbn/nevernote/config/InitializationException.java
src/cx/fbn/nevernote/sql/DatabaseConnection.java
src/cx/fbn/nevernote/sql/requests/DatabaseRequest.java
src/cx/fbn/nevernote/sql/runners/RDatabaseConnection.java
src/cx/fbn/nevernote/threads/CounterRunner.java
src/cx/fbn/nevernote/threads/DBRunner.java
src/cx/fbn/nevernote/threads/IndexRunner.java
src/cx/fbn/nevernote/threads/SaveRunner.java
src/cx/fbn/nevernote/threads/SyncRunner.java