agora inbox for pljava-dev@postgresql.org
help / color / mirror / Atom feed[Pljava-dev] java.sql.SQLException: An attempt was made to call a PostgreSQL backend function while main thread was not in the JVM
4+ messages / 0 participants
[nested] [flat]
* [Pljava-dev] java.sql.SQLException: An attempt was made to call a PostgreSQL backend function while main thread was not in the JVM
@ 2004-09-19 16:00
0 siblings, 2 replies; 4+ messages in thread
From: @ 2004-09-19 16:00 UTC (permalink / raw)
Hi!
I am repeatedly calling SQL function, and trigger function fired by
"UPDATE" in sql function crashes with folowing exception. Crash is
reliable after 100 calls.
java.sql.SQLException: ERROR: java.sql.SQLException: An attempt was made
to call a PostgreSQL backend function while main thread was not in the JVM
org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1130)
org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:933)
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:139)
org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:346)
org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:294)
org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:285)
Exception is generated by native method in class
org.postgresql.pljava.internal.TriggerData function
public boolean isFiredAfter() throws SQLException
{
synchronized(Backend.THREADLOCK)
{
>>> return this._isFiredAfter();
}
}
Does anybody knows, what is wrong?
Petr Michalek
^ permalink raw reply [nested|flat] 4+ messages in thread
* [Pljava-dev] java.sql.SQLException: An attempt was made to call a PostgreSQL backend function while main thread was not in the JVM
@ 2004-09-19 16:19
parent:
1 sibling, 0 replies; 4+ messages in thread
From: @ 2004-09-19 16:19 UTC (permalink / raw)
Petr,
> Hi!
>
> I am repeatedly calling SQL function, and trigger function fired by
> "UPDATE" in sql function crashes with folowing exception. Crash is
> reliable after 100 calls.
>
> java.sql.SQLException: ERROR: java.sql.SQLException: An attempt was
> made to call a PostgreSQL backend function while main thread was not
> in the JVM
> org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1130)
> org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:933)
>
> org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:139)
>
> org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:346)
>
> org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:294)
>
> org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:285)
>
>
> Exception is generated by native method in class
> org.postgresql.pljava.internal.TriggerData function
>
> public boolean isFiredAfter() throws SQLException
> {
> synchronized(Backend.THREADLOCK)
> {
> >>> return this._isFiredAfter();
> }
> }
I'd like to see the error generated by the backend (the backtrace above
is from the client driver). Can you copy that from the backend log and
email it to me? Also, info concerning the versions of postgresql,
pljava, and java is helpful. A code example that I can run in order to
reproduce your problem is of course ideal.
Thanks,
Thomas Hallgren
^ permalink raw reply [nested|flat] 4+ messages in thread
* [Pljava-dev] java.sql.SQLException: An attempt was made to call a PostgreSQL backend function while main thread was not in the JVM - RESOLVED!
@ 2004-09-19 16:53
parent:
1 sibling, 1 reply; 4+ messages in thread
From: @ 2004-09-19 16:53 UTC (permalink / raw)
Thomas Hallgren wrote:
> Petr,
>
>> Hi!
>>
>> I am repeatedly calling SQL function, and trigger function fired by
>> "UPDATE" in sql function crashes with folowing exception. Crash is
>> reliable after 100 calls.
>>
>> java.sql.SQLException: ERROR: java.sql.SQLException: An attempt was
>> made to call a PostgreSQL backend function while main thread was not
>> in the JVM
>> org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1130)
>> org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:933)
>>
>> org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:139)
>>
>> org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:346)
>>
>> org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:294)
>>
>> org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:285)
>>
>>
>> Exception is generated by native method in class
>> org.postgresql.pljava.internal.TriggerData function
>>
>> public boolean isFiredAfter() throws SQLException
>> {
>> synchronized(Backend.THREADLOCK)
>> {
>> >>> return this._isFiredAfter();
>> }
>> }
>
>
> I'd like to see the error generated by the backend (the backtrace above
> is from the client driver). Can you copy that from the backend log and
> email it to me? Also, info concerning the versions of postgresql,
> pljava, and java is helpful. A code example that I can run in order to
> reproduce your problem is of course ideal.
>
> Thanks,
>
> Thomas Hallgren
>
>
>
Hi!
It was my fault! I forgot to close prepared statement!
Petr Michalek
Postgresql 8.0.0beta2
Java JDK1.5 RC
Backend log example:
LOG: database system was shut down at 2004-09-19 18:40:51 CEST
LOG: checkpoint record is at 0/979AAA9C
LOG: redo record is at 0/979AAA9C; undo record is at 0/0; shutdown TRUE
LOG: next transaction ID: 1463312; next OID: 82024
LOG: database system is ready
LOG: unexpected EOF on client connection
WARNING: Freeing plan using finalizer. Someone forgot to close a
PreparedStatement
.
.
.
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
LOG: server process (PID 22300) was terminated by signal 6
LOG: terminating any other active server processes
LOG: all server processes terminated; reinitializing
LOG: database system was interrupted at 2004-09-19 18:40:57 CEST
LOG: checkpoint record is at 0/979AAA9C
LOG: redo record is at 0/979AAA9C; undo record is at 0/0; shutdown TRUE
LOG: next transaction ID: 1463312; next OID: 82024
LOG: database system was not properly shut down; automatic recovery in
progress
LOG: redo starts at 0/979AAAD8
LOG: record with zero length at 0/97A96E54
LOG: redo done at 0/97A96E14
LOG: database system is ready
^ permalink raw reply [nested|flat] 4+ messages in thread
* [Pljava-dev] java.sql.SQLException: An attempt was made to call a PostgreSQL backend function while main thread was not in the JVM - RESOLVED!
@ 2004-09-19 17:14
parent:
0 siblings, 0 replies; 4+ messages in thread
From: @ 2004-09-19 17:14 UTC (permalink / raw)
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
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2004-09-19 17:14 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-09-19 16:00 [Pljava-dev] java.sql.SQLException: An attempt was made to call a PostgreSQL backend function while main thread was not in the JVM
2004-09-19 16:19 `
2004-09-19 16:53 ` [Pljava-dev] java.sql.SQLException: An attempt was made to call a PostgreSQL backend function while main thread was not in the JVM - RESOLVED!
2004-09-19 17:14 ` [Pljava-dev] java.sql.SQLException: An attempt was made to call a PostgreSQL backend function while main thread was not in the JVM - RESOLVED!
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox