Re: Is SPI safe to use in multi-threaded PL/Java?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "MauMau" <maumau307(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Is SPI safe to use in multi-threaded PL/Java?
Date: 2014-03-11 13:51:59
Message-ID: 11347.1394545919@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"MauMau" <maumau307(at)gmail(dot)com> writes:
> From: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
>> When it breaks, we're not going to be concerned.

> I may not understand your nuance. Which of the following do you mean?

> * PL/Java's design is dangerous in terms of the mixture of single- and
> multi-threading, and we cannot be 100% sure whether there's really no
> problem.

That, more or less. There is exactly zero provision in the Postgres
code for multiple threads to exist inside a backend process. It's
possible that PL/Java manages to completely insulate the Java world
from the C world, so that the C code never sees more than one thread.
But any leakage at all in that abstraction is probably going to cause
bugs; and as I said, we (PG hackers) are not going to consider such
bugs to be our problem.

On platforms where the standard libc supports threading (which is most,
these days), I'd be particularly worried about leakage along the path
java -> libc -> postgres. If libc becomes aware that there are multiple
threads executing inside the process, it's likely to change behaviors.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2014-03-11 13:57:56 Re: db_user_namespace a "temporary measure"
Previous Message Magnus Hagander 2014-03-11 13:47:49 Re: db_user_namespace a "temporary measure"