From: thomas at tada.se (Thomas Hallgren) Date: Wed, 22 Feb 2006 08:49:47 +0100 Subject: [Pljava-dev] Multithreading In-Reply-To: <802147018@web.de> References: <802147018@web.de> Message-ID: <43FC179B.9000005@tada.se> Patrick Peisker wrote: > Problems: > > - Call a webservice from the thread: On creating an axis service object the jvm hangs up and the database automatically shut downs and restart! > > Any ideas? > > The PostgreSQL backend is inherently single-threaded and this puts some limitations on PL/Java. The PL/Java classloader uses the backend SPI layer to load its classes. Consider the following scenario: 1. Your request gets served appropriately and something is put in the queue. 2. The Java call that the PostgreSQL backend issued returns and the backend does other things. 3. The JVM decides to do some work in another thread and that causes a class to be loaded. When 3 occurs, you suddenly have 2 threads (the main thread that 'does other things' and the new Java thread) attempting access to the backend simultaneously. This will cause the Java thread to wait. And it will remain waiting until the next call that goes into the Java domain arrives from the backend (there's of course no guarantee such a call will ever arrive). The current workaround for this problem is to ensure that all needed classes are loaded in the main thread prior to the return from the call. This scenario can be perceived as a hung JVM but I've never seen it result in automatic shutdown (not with the 1.2 release anyway). In order to help, I must know what versions are you using (PL/Java, PostgreSQL, JVM, and OS) and whats logged in the backend when the shutdown occurs. Kind Regards, Thomas Hallgren