• 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/Bookmark

Filed under Java, Techlist, Tools | 1 Comment »



One Response 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.



Leave a Reply

Click here to cancel reply.

Deployment automation for Java application running on Websphere, WebLogic and JBoss

Archives

  • March 2010
  • February 2010
  • January 2010
  • December 2009
  • November 2009
  • October 2009
  • September 2009
  • August 2009
  • July 2009
  • June 2009
  • May 2009
  • April 2009

Xebia Sites

  • Xebia Corporate
  • Xebia France
  • Xebia India

Categories

  • Java (282)
  • Agile (109)
  • General (50)
  • Testing (42)
  • Performance (42)
  • Hibernate (36)
  • Scrum (33)
  • Podcast (31)
  • Architecture (31)
  • Spring (28)
  • SOA (24)
  • Maven (22)
  • Project Management (22)
  • Middleware (23)
    • Deployment (14)
  • Flex (17)
  • JPA (17)
  • Eclipse (15)
  • Xebia Labs (15)
  • Quality Assurance (14)

Tag Cloud

    Closures Seam Semantic Web Poppendieck SOA Agile product owner Performance Java Groovy XML IntelliJ Architecture Introduction to Agile Scala esb Testing Agile Awareness Workshop Xebia Spring Ajax qcon JavaOne Maven Lean fitnesse Grails Hibernate Functional Programming Scrum