You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Eric Rotick <pc...@gmail.com> on 2008/11/27 13:15:36 UTC

Database locked running site

I've cracked this problem but I though I'd let others know to try and avoid
them falling into the same trap.

I was having a problem running site whereby the database used in the test
section was locked by another user.

The test involves setting up a fresh database environment for which I use
the exec plugin to drop the database, create the database and then load in
the test data.

If I ran test everything was OK. If I ran cobertura:cobertura then
everything was OK. If I ran site, then it failed saying the database was
locked by another user. It seemed to fail at the point where Cobertura has
instrumented the Java in readiness for the test run, and the call to drop
the database reports that the database was locked by another user.

I know that the database is not in use by any other application outside of
maven and I suspected that it was the first run of the two tests; one to run
it without instrumentation and one to run it with instrumentation.

My initial thought was the sql plugin may be holding on to some database
connection so I changed the use of the sql plugin to use the exec pluign and
call the database command line utilities directly. This had no effect which
was surprising.

I then remembered that part of the database setup involved a small Java
application which was being called by the exec plugin java goal; in essence,
it was being run in the same JVM as everything else. As this was a '"simple"
test function, it didn't ensure that all the resources were released and so
was the culprit. Fixing this solved the problem.

When the test was run once, the resources were released when the JVM exited.
When the test was run twice, within the same JVM, the first run did not
release the resources and hey presto!

I hope this stops someone making the same stupid mistake.

Eric.