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. > 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. -- Knut Anders
