[Pljava-dev] java.sql.SQLException: An attempt was made to call a PostgreSQL backend function while main thread was not in the JVM - RESOLVED!

From: thhal at mailblocks(dot)com (Thomas Hallgren)
To:
Subject: [Pljava-dev] java.sql.SQLException: An attempt was made to call a PostgreSQL backend function while main thread was not in the JVM - RESOLVED!
Date: 2004-09-19 17:14:27
Message-ID: thhal-09lYpAmGuUykxaxJXjS9GvCmyYEaYxV@mailblocks.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pljava-dev

Petr Mich?lek wrote:

> It was my fault! I forgot to close prepared statement!
>
> WARNING: Freeing plan using finalizer. Someone forgot to close a
> PreparedStatement
> LOG: Exception
> LOG: in thread "main"
> java.sql.SQLException: An attempt was made to call a PostgreSQL
> backend function while main thread was not in the JVM
> at org.postgresql.pljava.internal.TriggerData._isFiredAfter(Native
> Method)
> at
> org.postgresql.pljava.internal.TriggerData.isFiredAfter(TriggerData.java:219)
>
> at
> com.aca.app.acc.core.postgresql.Triggers.document1(Triggers.java:569)
> ERROR: java.sql.SQLException: An attempt was made to call a
> PostgreSQL backend function while main thread was not in the JVM

Ok, that explains it. What happens is that eventually a finalizer is
called from a thread other then the one spawned by the original function
call. That thread in turn makes an attempt to call back into the backend
C functions in order to free up an SPI execution plan. The that call
arrives at a time when the backend is not executing a Java function so
PL/Java has no choice but to let it bounce back into Java with an
exception. The PostgreSQL backend is inherently single threaded. It
cannot serve multiple requests stemming from different places at the
same time.

I might improve this some time in the future by introducing some kind of
"death row" that is processed when it's safe.

Regards,

Thomas Hallgren

In response to

Browse pljava-dev by date

  From Date Subject
Next Message Thomas Hallgren 2004-09-24 14:42:25 [Pljava-dev] ANN: PL/Java 1.0.0.b5 now available for download.
Previous Message Petr Michálek 2004-09-19 16:53:48 [Pljava-dev] java.sql.SQLException: An attempt was made to call a PostgreSQL backend function while main thread was not in the JVM - RESOLVED!