Date: Mon, 4 Feb 2013 19:18:59 +0200 From: Konstantin Belousov <kostikbel@gmail.com> To: Achilleas Mantzios <achill@matrix.gatewaynet.com> Cc: freebsd-java@freebsd.org Subject: Re: Re: Re: Re: Re: FreeBSD pl/java problem : backend hangs Message-ID: <20130204171859.GB2522@kib.kiev.ua> In-Reply-To: <1917151.YiRb4P31Ma@smadev.internal.net> References: <5933829.WYzpjKtO0p@smadev.internal.net> <1794514.P32sUeWV4B@smadev.internal.net> <3454957.mdnJNsQM6V@smadev.internal.net> <1917151.YiRb4P31Ma@smadev.internal.net>
next in thread | previous in thread | raw e-mail | index | archive | help
--g7RZQ2HC70+y+NLc Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Feb 04, 2013 at 07:00:18PM +0200, Achilleas Mantzios wrote: > It surely is a problem with running JNI from within postgresql in FreeBSD= : >=20 > Wrote a very small C postgresql function which simply calls JNI > and it hangs as well. >=20 > #include "postgres.h" > =20 > #include "utils/elog.h" > #include "utils/palloc.h" > #include "utils/array.h" > #include "utils/builtins.h" > #include "storage/bufpage.h" > #include "catalog/pg_type.h" >=20 > #include <jni.h> >=20 > PG_MODULE_MAGIC; >=20 > PG_FUNCTION_INFO_V1(jnitest); > Datum jnitest(PG_FUNCTION_ARGS); >=20 > Datum > jnitest(PG_FUNCTION_ARGS) > { > int res; > JNIEnv *env; > JavaVM *jvm; > JavaVMInitArgs vm_args; > JavaVMOption *options=3DNULL; > vm_args.version =3D 0x00010002; > vm_args.options =3D options; > vm_args.nOptions =3D 0; > vm_args.ignoreUnrecognized =3D JNI_TRUE; > /* Create the Java VM */ > res =3D JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args); >=20 > PG_RETURN_POINTER(res); > } >=20 > create function jnitest() RETURNS integer LANGUAGE c AS '$libdir/jnitest'= , 'jnitest'; >=20 > dynacom=3D# select jnitest(); >=20 > ^^^ hangs, it seems the call to res =3D JNI_CreateJavaVM(&jvm, (void**)&e= nv, &vm_args); > just never completes >=20 > So, this must be a FreeBSD/PostgreSQL/JNI thing. >=20 > Any help/where to go from here would be very welcome. Try to start the postgres daemon with 'LD_PRELOAD=3D/lib/libthr.so.3' env variable set. >=20 > On ?????? 04 ?????? 2013 17:48:20 Achilleas Mantzios wrote: > > It seems that it gets hung in JNI_CreateJavaVM. > >=20 > > I can write and run standalone JNI programs outside postgrsesql (even a= s postgres user), > > but when i try to run it from within postgres, then it gets hang. > >=20 > > Any ideas? > >=20 > > On ?????? 04 ?????? 2013 17:16:27 Achilleas Mantzios wrote: > > > I am thinking of trying to address this problem twofold : > > >=20 > > > 1) establish a connection with the pl/java people > > > 2) trying to go back and forth from there and here to try to debug th= e problem > > >=20 > > > Lets wait for some recommendation/help from there, and then i'll get = back > > > to this list for more. > > >=20 > > > On ?????? 04 ?????? 2013 16:09:56 Achilleas Mantzios wrote: > > > > Thanx Ronald, > > > >=20 > > > > postgres@smadev:~> jstack 384 > > > > 384: Unable to open socket file: target process not responding or H= otSpot VM not loaded > > > > The -F option can be used when the target process is not responding > > > >=20 > > > > Also jstack -F fails as well > > > > postgres@smadev:~> jstack -F 384 > > > > Attaching to process ID 384, please wait... > > > > Exception in thread "main" java.lang.reflect.InvocationTargetExcept= ion > > > > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Meth= od) > > > > at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethod= AccessorImpl.java:57) > > > > at sun.reflect.DelegatingMethodAccessorImpl.invoke(Delegati= ngMethodAccessorImpl.java:43) > > > > at java.lang.reflect.Method.invoke(Method.java:616) > > > > at sun.tools.jstack.JStack.runJStackTool(JStack.java:136) > > > > at sun.tools.jstack.JStack.main(JStack.java:102) > > > > Caused by: sun.jvm.hotspot.debugger.UnalignedAddressException: Tryi= ng to read at address: 0x746f705c6c4f4867 with alignment: 4 > > > > at sun.jvm.hotspot.debugger.bsd.BsdDebuggerLocal$1.checkAli= gnment(BsdDebuggerLocal.java:181) > > > > at sun.jvm.hotspot.debugger.bsd.BsdDebuggerLocal.readCInteg= er(BsdDebuggerLocal.java:478) > > > > at sun.jvm.hotspot.debugger.DebuggerBase.readAddressValue(D= ebuggerBase.java:454) > > > > at sun.jvm.hotspot.debugger.bsd.BsdDebuggerLocal.readAddres= s(BsdDebuggerLocal.java:423) > > > > at sun.jvm.hotspot.debugger.bsd.BsdAddress.getAddressAt(Bsd= Address.java:74) > > > > at sun.jvm.hotspot.HotSpotTypeDataBase.readVMTypes(HotSpotT= ypeDataBase.java:108) > > > > at sun.jvm.hotspot.HotSpotTypeDataBase.<init>(HotSpotTypeDa= taBase.java:85) > > > > at sun.jvm.hotspot.bugspot.BugSpotAgent.setupVM(BugSpotAgen= t.java:574) > > > > at sun.jvm.hotspot.bugspot.BugSpotAgent.go(BugSpotAgent.jav= a:495) > > > > at sun.jvm.hotspot.bugspot.BugSpotAgent.attach(BugSpotAgent= =2Ejava:333) > > > > at sun.jvm.hotspot.tools.Tool.start(Tool.java:163) > > > > at sun.jvm.hotspot.tools.JStack.main(JStack.java:86) > > > >=20 > > > >=20 > > > > On ???????????? 04 ??????????=9D 2013 14:47:13 you wrote: > > > > > I have no experience running java as a backend of pgsql. > > > > > Can you run jstack on the backend? > > > > >=20 > > > > > Ronald. > > > > >=20 > > > > > On Mon, 04 Feb 2013 14:17:22 +0100, Achilleas Mantzios =20 > > > > > <achill@matrix.gatewaynet.com> wrote: > > > > >=20 > > > > > > Hello community, > > > > > > > > > > > > I am running postgresql 9.2.2 with > > > > > > openjdk version "1.6.0_32" > > > > > > OpenJDK Runtime Environment (build 1.6.0_32-b25) > > > > > > OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode) > > > > > > On FreeBSD 8.3-RELEASE > > > > > > > > > > > > I am having trouble even running simple tests like : > > > > > > CREATE FUNCTION getsysprop(VARCHAR) > > > > > > RETURNS VARCHAR > > > > > > AS 'java.lang.System.getProperty' > > > > > > LANGUAGE java; > > > > > > > > > > > > SELECT getsysprop('user.home'); > > > > > > > > > > > > When i do that, the session hangs, and have to kill -9 the back= end. > > > > > > > > > > > > Searching with truss got : > > > > > > > > > > > > gettimeofday({1359983241.596250 },0x0) =3D 0 (0x0) > > > > > > gettimeofday({1359983241.596275 },0x0) =3D 0 (0x0) > > > > > > gettimeofday({1359983241.596300 },0x0) =3D 0 (0x0) > > > > > > gettimeofday({1359983241.596327 },0x0) =3D 0 (0x0) > > > > > > gettimeofday({1359983241.596352 },0x0) =3D 0 (0x0) > > > > > > gettimeofday({1359983241.596378 },0x0) =3D 0 (0x0) > > > > > > gettimeofday({1359983241.596403 },0x0) =3D 0 (0x0) > > > > > > gettimeofday({1359983241.596431 },0x0) =3D 0 (0x0) > > > > > > gettimeofday({1359983241.596458 },0x0) =3D 0 (0x0) > > > > > > gettimeofday({1359983241.596482 },0x0) =3D 0 (0x0) > > > > > > gettimeofday({1359983241.596507 },0x0) =3D 0 (0x0) > > > > > > gettimeofday({1359983241.596532 },0x0) =3D 0 (0x0) > > > > > > gettimeofday({1359983241.596556 },0x0) =3D 0 (0x0) > > > > > > _umtx_op(0x7fffffffc7e8,0x3,0x1,0x0,0x0,0x1) =3D 0 (0x0) > > > > > > sigprocmask(SIG_BLOCK,SIGHUP|SIGINT|SIGQUIT|SIGABRT|SIGEMT|SIGK= ILL|SIGSYS|SIGPIPE|SIGALRM|SIGTERM|SIGURG|SIGSTOP|SIGTSTP|SIGCONT|SIGCHLD|S= IGTTIN|SIGTTOU|SIGIO|SIGXCPU|SIGXFSZ|SIGVTALRM|SIGPROF|SIGWINCH|SIGINFO|SIG= USR1|SIGUSR2,0x0) =20 > > > > > > =3D 0 (0x0) > > > > > > sigprocmask(SIG_SETMASK,0x0,0x0) =3D 0 (0x0) > > > > > > sigprocmask(SIG_BLOCK,SIGHUP|SIGINT|SIGQUIT|SIGABRT|SIGEMT|SIGK= ILL|SIGSYS|SIGPIPE|SIGALRM|SIGTERM|SIGURG|SIGSTOP|SIGTSTP|SIGCONT|SIGCHLD|S= IGTTIN|SIGTTOU|SIGIO|SIGXCPU|SIGXFSZ|SIGVTALRM|SIGPROF|SIGWINCH|SIGINFO|SIG= USR1|SIGUSR2,0x0) =20 > > > > > > =3D 0 (0x0) > > > > > > sigprocmask(SIG_SETMASK,0x0,0x0) =3D 0 (0x0) > > > > > > > > > > > > while ktrace gave : > > > > > > > > > > > > 98910 initial thread CALL gettimeofday(0x7fffffffc900,0) > > > > > > 98910 initial thread RET gettimeofday 0 > > > > > > 98910 initial thread CALL gettimeofday(0x7fffffffc900,0) > > > > > > 98910 initial thread RET gettimeofday 0 > > > > > > 98910 initial thread CALL gettimeofday(0x7fffffffc900,0) > > > > > > 98910 initial thread RET gettimeofday 0 > > > > > > 98910 initial thread CALL gettimeofday(0x7fffffffc900,0) > > > > > > 98910 initial thread RET gettimeofday 0 > > > > > > 98910 initial thread CALL gettimeofday(0x7fffffffc940,0) > > > > > > 98910 initial thread RET gettimeofday 0 > > > > > > 98910 initial thread CALL _umtx_op(0x7fffffffc7e8,0x3,0x1,0,0) > > > > > > 98910 initial thread RET _umtx_op 0 > > > > > > 98910 initial thread CALL =20 > > > > > > sigprocmask(SIG_BLOCK,0x7fffffffc780,0x8016167d8) > > > > > > 98910 initial thread RET sigprocmask 0 > > > > > > 98910 initial thread CALL sigprocmask(SIG_SETMASK,0x8016167d8= ,0) > > > > > > 98910 initial thread RET sigprocmask 0 > > > > > > 98910 initial thread CALL =20 > > > > > > sigprocmask(SIG_BLOCK,0x7fffffffc6e0,0x8016167d8) > > > > > > 98910 initial thread RET sigprocmask 0 > > > > > > 98910 initial thread CALL sigprocmask(SIG_SETMASK,0x8016167d8= ,0) > > > > > > 98910 initial thread RET sigprocmask 0 > > > > > > 98910 initial thread CALL _umtx_op(0x8f8dc4280,0x11,0,0,0) > > > > > > > > > > > > I found some relevant problems with FreeBSD systems hanging aft= er an =20 > > > > > > _umtx_op but all those point > > > > > > to threading problems that now are solved. I found nothing mode= rn about =20 > > > > > > _umtx_op. > > > > > > > > > > > > I know FreeBSD is not a "Tier-1" platform for postgresql (nor j= ava), but =20 > > > > > > this is my main platform and i'd like > > > > > > to stick with this. > > > > > > > > > > > > Is there anything i could do to get closer to make pl/java work= with =20 > > > > > > FreeBSD? > > > > > > > > > > > > Also read this =20 > > > > > > http://postgresql.1045698.n5.nabble.com/Java-VM-stalls-during-q= uot-install-jar-quot-td3290754.html =20 > > > > > > thread. > > > > > > Very close to my situation. JNI standalone also worked for me. > > > > > > > > > > > > Any hints/pointers ? > > > > > > > > > > > > - > > > > > > Achilleas Mantzios > > > > > > IT DEV > > > > > > IT DEPT > > > > > > Dynacom Tankers Mgmt > > > > > > _______________________________________________ > > > > > > freebsd-java@freebsd.org mailing list > > > > > > http://lists.freebsd.org/mailman/listinfo/freebsd-java > > > > > > To unsubscribe, send any mail to "freebsd-java-unsubscribe@free= bsd.org" > > > > - > > > > Achilleas Mantzios > > > > IT DEV > > > > IT DEPT > > > > Dynacom Tankers Mgmt > > > > _______________________________________________ > > > > freebsd-java@freebsd.org mailing list > > > > http://lists.freebsd.org/mailman/listinfo/freebsd-java > > > > To unsubscribe, send any mail to "freebsd-java-unsubscribe@freebsd.= org" > > > - > > > Achilleas Mantzios > > > IT DEV > > > IT DEPT > > > Dynacom Tankers Mgmt > > - > > Achilleas Mantzios > > IT DEV > > IT DEPT > > _______________________________________________ > > freebsd-java@freebsd.org mailing list > > http://lists.freebsd.org/mailman/listinfo/freebsd-java > > To unsubscribe, send any mail to "freebsd-java-unsubscribe@freebsd.org" > - > Achilleas Mantzios > IT DEV > IT DEPT > Dynacom Tankers Mgmt > _______________________________________________ > freebsd-java@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-java > To unsubscribe, send any mail to "freebsd-java-unsubscribe@freebsd.org" --g7RZQ2HC70+y+NLc Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (FreeBSD) iQIcBAEBAgAGBQJRD+2CAAoJEJDCuSvBvK1BltQP/2VRLGT7KVfdWb1Dq+/deY8k 5YyYfUAjvyhfHrgu5IXat46IXDqRDUEA8ebpD1cCAVryw0FiP+r+tyPXcUBNLyOA O3YXQI4ribe9AK9Eygl/zeEuQ3jVFxuZMi2KHNYOSNDo5pHbLu7wYtlZYt9dsZ1I du0fVssLfQZ22soUOsjO7mUS55IFqPjYIVE9gJSM7J+t7n/+PdwH8i1s5hL/rADB 1u69LYUGf9vWaZvbcroB7qpeDOAuQ2qoVlmvKDMWpCQ+zYdgv+xIuEODbUTbhb/l Sm52nM5nhdwXCNuE8AS91JvX7Sz8v/zlQXobVLBUpvWPjitUk+HPpghHgACxKlbC zhw/my4vHZmZIC0bfPhjpDcw1wUQ+SFGNDpsVropLLgsZqDEBUe7ZtMuVqR+B8RV 6Jf+rY21RT6xdbLvmffrbxOjNcFXS5y71S1C+BCqg+RQEbFyOnThOwFq+6xlgJfy ZZXhWN0PjLceeB809BkTzGeShCpy22Si5LGY3nWe2nevVXOsRMkIjrrDxo8jbm7m DrV+i44Dk+MN3ETCbafyqRmC94f1ootWurXfhHpAdfEhG1anql6Ondo975nXwVN6 9vJlknOqw6AAMP2SLB/hyE3gY5Pw1MUGEBlTof+BYdl63c/obD3O0gK0CMk/m66W AxrSBiU0nzvpFwAbowrE =CBaQ -----END PGP SIGNATURE----- --g7RZQ2HC70+y+NLc--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130204171859.GB2522>