On 12/06/2013 01:28 PM, Knut Anders Hatlen wrote:
Dyre Tjeldvoll <[email protected]> writes:

Hi,

I'm wondering if it is safe

to call to
DriverManager.getConncetion("jdbc:derby:somedb;shutdown=true") and
DriverManager.getConncetion("jdbc:derby:;shutdown=true")

from two threads simultaneously?

Apparently not... :-/

https://issues.apache.org/jira/browse/DERBY-4447 talks about adding a
block mechanism, where one of the goals is to allow graceful shutdowns
when multiple threads access the database.

Well, it is not super important for me, I just keep a ref count for the engine in the application and delay shutdown until the ref count is zero... and that seems to work.

But I don't think the doc mentions that you should avoid this...


I seem to be in a situation where these two calls deadlock.

The first thread is at

"main" prio=10 tid=0x00007ff04c00a000 nid=0x639e waiting on condition
[0x00007ff05102d000]
    java.lang.Thread.State: TIMED_WAITING (sleeping)
        at java.lang.Thread.sleep(Native Method)
        at
org.apache.derby.impl.store.raw.data.RAFContainer.clean(RAFContainer.java:518)
        - locked <0x000000078665bbb0> (a 
org.apache.derby.impl.store.raw.data.RAFContainer4)

[...]

while the second is at

"Thread-2" prio=10 tid=0x00007ff04c386000 nid=0x63c0 waiting on
condition [0x00007ff0442c6000]
    java.lang.Thread.State: RUNNABLE
        at 
org.apache.derby.iapi.services.context.ContextManager.<init>(ContextManager.java:121)

How odd... That line is

     private final HashMap<String,CtxStack> ctxTable = new 
HashMap<String,CtxStack>();

which shouldn't do any locking, so far as I can see.

Yeah, I found that odd too - but I struggled a bit to find the right version of jstack - the one in my path didn't work at all - so maybe the one I used isn't quite right either...

Regards

Dyre

Reply via email to