[Pljava-dev] Is it safe to use multi-threaded PL/Java in single-threaded postgres process?

From: maumau307 at gmail(dot)com (MauMau)
To:
Subject: [Pljava-dev] Is it safe to use multi-threaded PL/Java in single-threaded postgres process?
Date: 2014-03-16 04:05:30
Message-ID: 0AF1495BB9BA466CAB0D57C2DCAB44DB@maumau
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pljava-dev

From: "Hal Hildebrand" <hal.hildebrand at me.com>
> So, I really think this question has been definitively answered.

Yes, I found a similar mail thread:

http://postgresql.1045698.n5.nabble.com/doubtful-PL-Java-s-activity-td5783047.html

But I understood that the person who raised the question did not show a test
case, nor the PL/Java community did not answer why PL/Java has no problem in
mixing multi-threaded code and single-threaded code.

> If you can produce a test case of your concerns which demonstrates the
> issue, we can discuss it.

I'd like to do so if I could do it, but I cannot. This is why I'm asking
this question. I want to believe PL/Java has no problem and want to use it.
I proposed using PL/Java to my colleagues. However, they are concerned
about this question. I want to convince them by showing how PL/Java is safe
in terms of theory.

> But the simple answer to your question is simply: yes.
> Pl/java obeys the rules and works according to spec.
> It does the right thing in the right way using the best practices.

Could you elaborate on this? The details should be the answer I'm looking
for.
As I said as below, it doesn't seem that PL/Java obeys the JNI spec, because
pljava.so is not compiled with -mt, -D_REENTRANT nor -D_POSIX_C_SOURCE. In
short, I'd like to know why it is safe to make JVM to load single-threaded
pljava.so.

>> FYI, JNI specification says that the code called from Java VM should be
>> built for multi-threading as follows. But postgres is not.
>>
>> http://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/design.html#wp9502
>>
>> [Excerpt]
>> Compiling, Loading and Linking Native Methods
>> Since the Java VM is multithreaded, native libraries should also be
>> compiled and linked with multithread aware native compilers. For example,
>> the -mt flag should be used for C++ code compiled with the Sun Studio
>> compiler. For code complied with the GNU gcc compiler, the
>> flags -D_REENTRANT or -D_POSIX_C_SOURCE should be used. For more
>> information please refer to the native compiler documentation.

Regards
MauMau

In response to

Responses

Browse pljava-dev by date

  From Date Subject
Next Message John R Pierce 2014-03-16 05:10:47 [Pljava-dev] Is it safe to use multi-threaded PL/Java in single-threaded postgres process?
Previous Message Hal Hildebrand 2014-03-16 02:04:59 [Pljava-dev] Is it safe to use multi-threaded PL/Java in single-threaded postgres process?