[Pljava-dev] Multithreading

From: thomas at tada(dot)se (Thomas Hallgren)
To:
Subject: [Pljava-dev] Multithreading
Date: 2006-02-22 07:49:47
Message-ID: 43FC179B.9000005@tada.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pljava-dev

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

In response to

Browse pljava-dev by date

  From Date Subject
Next Message Patrick Peisker 2006-02-22 08:03:09 [Pljava-dev] Multithreading
Previous Message Patrick Peisker 2006-02-22 07:01:37 [Pljava-dev] Multithreading