Re: FastPath blocked when ERROR is thrown

Lists: pgsql-jdbc
From: "Yi Lin" <ylin30(at)cs(dot)mcgill(dot)ca>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: FastPath blocked when ERROR is thrown
Date: 2006-04-11 22:06:15
Message-ID: 59619.132.206.52.74.1144793175.squirrel@mail.cs.mcgill.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

HI

I used java API FastPath.fastpath(fid, ...) to call a C function
PGfn(conn, fid,...) in the kernal. But if there is an exception (i.e.,
ERROR messages is thrown in the backend due to elog(ERROR, ...)), the
FastPath.fastpath(fid, ..) is blocked and never returns. The DB backend is
also dead. I have to "pkill -9 post" in order to restore everything. Can
anyone give a clue of what the problems should be? Where should are the
bugs possibly located?

The java codes is attached:

public boolean putWriteSet(java.sql.Connection conn, byte[] writeSet)
throws SQLException
{
Fastpath fp = ((org.postgresql.Connection)conn).getFastpathAPI();
FastpathArg[] args = new FastpathArg[1];
args[0] = new FastpathArg(writeSet);
fp.fastpath(2075, false, args); //to apply writeset, indirectly call
PQfn(conn, 2075, ...) implemented in the kernal in C.

return true;
}

I am not the original author of C version PQfn(.,2075,..) so I have no
idea where and how to debug it. I doubt that the blocking is due to
implementation of C part instead of Java part. But I don't know how to
start my debugging.

thanks in advance!

=======================================
Yi Lin

Ph.D. candidate
School of Computer Science
McGill University
Montreal, Quebec,Canada
URL: http://www.cs.mcgill.ca/~ylin30/

\\\ $ ///
@ @
======o0o==0==o0o======================


From: Dave Cramer <pg(at)fastcrypt(dot)com>
To: Yi Lin <ylin30(at)cs(dot)mcgill(dot)ca>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: FastPath blocked when ERROR is thrown
Date: 2006-04-11 22:43:21
Message-ID: AC201B08-CFA2-4F2F-9C20-2240A1429B9D@fastcrypt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

If you managed to kill the backend, then it's likely the C function
that did it. In order to debug it you can use gdb

Can you call the C function from psql without crashing ?

Dave
On 11-Apr-06, at 6:06 PM, Yi Lin wrote:

> HI
>
> I used java API FastPath.fastpath(fid, ...) to call a C function
> PGfn(conn, fid,...) in the kernal. But if there is an exception (i.e.,
> ERROR messages is thrown in the backend due to elog(ERROR, ...)), the
> FastPath.fastpath(fid, ..) is blocked and never returns. The DB
> backend is
> also dead. I have to "pkill -9 post" in order to restore
> everything. Can
> anyone give a clue of what the problems should be? Where should are
> the
> bugs possibly located?
>
> The java codes is attached:
>
> public boolean putWriteSet(java.sql.Connection conn, byte[] writeSet)
> throws SQLException
> {
> Fastpath fp = ((org.postgresql.Connection)conn).getFastpathAPI();
> FastpathArg[] args = new FastpathArg[1];
> args[0] = new FastpathArg(writeSet);
> fp.fastpath(2075, false, args); //to apply writeset,
> indirectly call
> PQfn(conn, 2075, ...) implemented in the kernal in C.
>
> return true;
> }
>
> I am not the original author of C version PQfn(.,2075,..) so I have no
> idea where and how to debug it. I doubt that the blocking is due to
> implementation of C part instead of Java part. But I don't know how to
> start my debugging.
>
> thanks in advance!
>
> =======================================
> Yi Lin
>
> Ph.D. candidate
> School of Computer Science
> McGill University
> Montreal, Quebec,Canada
> URL: http://www.cs.mcgill.ca/~ylin30/
>
> \\\ $ ///
> @ @
> ======o0o==0==o0o======================
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster
>


From: Kris Jurka <books(at)ejurka(dot)com>
To: Yi Lin <ylin30(at)cs(dot)mcgill(dot)ca>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: FastPath blocked when ERROR is thrown
Date: 2006-04-11 22:59:33
Message-ID: Pine.BSO.4.63.0604111756500.2028@leary2.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

On Tue, 11 Apr 2006, Yi Lin wrote:

> I used java API FastPath.fastpath(fid, ...) to call a C function
> PGfn(conn, fid,...) in the kernal. But if there is an exception (i.e.,
> ERROR messages is thrown in the backend due to elog(ERROR, ...)), the
> FastPath.fastpath(fid, ..) is blocked and never returns.

The attached code runs fine with the cvs jdbc driver and a 8.0.7 server.
You haven't mentioned your versions, but this code hasn't changed recently
so anything relatively new should be fine.

How do you know the function is erroring out? What does the server log
say?

Kris Jurka

Attachment Content-Type Size
FP.java text/plain 1.2 KB