• Home
  • RSS Feed
  • Log in


HSQLDB “database already in use by another process” exceptions on UNIX
Posted by Andrew Phillips mid-afternoon: March 20th, 2009

Installing a simple Grails application in Tomcat on Linux should really have been the most straightforward of tasks. Instead, I spent a progressively more frustrating morning chasing down a “helpful” feature of HSQLDB that was causing the startup to fail with

org.hsqldb.HsqlException: The database is already in use by another process:
org.hsqldb.persist.NIOLockFile@6b67bdbe[file =/myDb.lck, exists=true, locked=false, valid=false,
fl=null]

exceptions. To save others from a similar waste of time, here’s the cause and a workaround:

Cause

Between versions 1.7.2. and 1.8.0.10., HSQLDB attempts to lock the files for file-based DBs in order to “[protect] the user from running the process twice with the same files and corrupting his data”, apparently. Unfortunately, if your DB files reside on NFS, which doesn’t support these locks, HSQLDB will blow up with the above exception.

It seems that there have been enough problems with this that HSQLDB has reverted to not using locks by default in 1.8.0.10., although this may be changed again in future versions, it seems.

Workaround(s)

  • Move your DB files to a non-NFS location
  • Upgrade to version 1.8.0.10. (or a pre-1.7.2. version)
  • Use a mem rather than a file DB

The details are described in this thread from the HSQLDB forums.

From what is mentioned there, it would seem to be possible to disable file locking somehow. I tried hsqldb.nio_data_file=false, but that doesn’t seem to do the trick. If anyone finds out how to do this please add a comment!

Share

Tags: Techlist
Filed under Java, Tools | 2 Comments »



2 Responses to “HSQLDB “database already in use by another process” exceptions on UNIX”



    Andrew Phillips Says:
    Posted at: March 23, 2009 at 9:21 am

    A colleague of mine raised a good point: “[Why] would you run Grails from an NFS share?”

    That’s completely true, of course – in this case, it was due to the server, Tomcat and web application configurations, and these should be modified appropriately.

    Reply


    Sandor Fiedler Says:
    Posted at: March 25, 2010 at 11:24 am

    Running in same problem using JBoss AS 5.1.0.GA (comes with HSQLDB 1.8.0.10) and finally got it working (at least for me):

    update hsqldbjar to 1.8.1.2
    edit the .properties file and setting hsqldb.nio_data_file=false and hsqldb.lock_file=false

    Reply


Leave a Reply

Click here to cancel reply.


Xebia Sites

  • Xebia Corporate
  • Xebia France
  • Xebia India
  • Xebia Sweden

Categories

  • Java (311)
  • Agile (181)
  • General (136)
  • Scrum (67)
  • Architecture (64)
  • Testing (59)
  • Performance (46)
  • Middleware (56)
    • Deployment (38)
  • Xebia Labs (39)
  • SOA (31)
  • Podcast (31)
  • Project Management (28)
  • Tools (26)
  • Uncategorized (20)
  • lean architecture (20)
  • Quality Assurance (17)
  • Articles (13)
  • Requirements Management (13)
  • Virtualization (19)

Tag Cloud

    Java Scrum SOA Frameworks agile architectuur lean architectuur Scala Agile Hibernate Ajax Xebia XML product owner Spring Eclipse lean architecture JPA Oracle Grails Flex Concurrency Control TDD Groovy JPA implementation patterns Architecture Maven Javascript Lean ACT Moving to India

Archives

  • February 2012
  • January 2012
  • December 2011
  • November 2011
  • October 2011
  • September 2011
  • August 2011
  • July 2011
  • June 2011
  • May 2011
  • April 2011
  • March 2011
Avatars by Sterling Adventures