agora inbox for pljava-dev@postgresql.org  
help / color / mirror / Atom feed
[Pljava-dev] Multithreading
4+ messages / 0 participants
[nested] [flat]

* [Pljava-dev] Multithreading
@ 2006-02-22 07:01  
  0 siblings, 1 reply; 4+ messages in thread

From:  @ 2006-02-22 07:01 UTC (permalink / raw)

Hi,

I have problems using pl/java and multithreading. My scenario:

- A pl/java trigger is called before an update is exceuted on a table. This trigger writes something into a queue (singelton pattern)

- A pl/java funtion creates a new thread (class which extends java.lang.thread)

- The new thread is asking the queue for entries and if there are some entries, the thread should call a webservice using axis

No Problems with:

- Creating new thread

- Write and read data from the queue

- Calling a webservice with axis from a pl/java function or trigger

Problems:

- Call a webservice from the thread: On creating  an axis service object the jvm hangs up and the database automatically shut downs and restart!

Any ideas?

thx,

Patrick





______________________________________________________________________
XXL-Speicher, PC-Virenschutz, Spartarife & mehr: Nur im WEB.DE Club!		
Jetzt gratis testen! http://freemail.web.de/home/landingpad/?mc=021130





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* [Pljava-dev] Multithreading
@ 2006-02-22 07:49  
  parent: 
  0 siblings, 0 replies; 4+ messages in thread

From:  @ 2006-02-22 07:49 UTC (permalink / raw)

Patrick Peisker wrote:
> Problems:
>
> - Call a webservice from the thread: On creating  an axis service object the jvm hangs up and the database automatically shut downs and restart!
>
> Any ideas?
>
>   
The PostgreSQL backend is inherently single-threaded and this puts some 
limitations on PL/Java. The PL/Java classloader uses the backend SPI 
layer to load its classes. Consider the following scenario:

1. Your request gets served appropriately and something is put in the queue.
2. The Java call that the PostgreSQL backend issued returns and the 
backend does other things.
3. The JVM decides to do some work in another thread and that causes a 
class to be loaded.

When 3 occurs, you suddenly have 2 threads (the main thread that 'does 
other things' and the new Java thread) attempting access to the backend 
simultaneously. This will cause the Java thread to wait. And it will 
remain waiting until the next call that goes into the Java domain 
arrives from the backend (there's of course no guarantee such a call 
will ever arrive). The current workaround for this problem is to ensure 
that all needed classes are loaded in the main thread prior to the 
return from the call.

This scenario can be perceived as a hung JVM but I've never seen it 
result in automatic shutdown (not with the 1.2 release anyway). In order 
to help, I must know what versions are you using (PL/Java, PostgreSQL, 
JVM, and OS) and whats logged in the backend when the shutdown occurs.

Kind Regards,
Thomas Hallgren





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* [Pljava-dev]  Multithreading
@ 2006-02-22 08:03  
  0 siblings, 1 reply; 4+ messages in thread

From:  @ 2006-02-22 08:03 UTC (permalink / raw)

Hi,

i use the PL/Java 1.1.0 released and here are some logs:

postgresql-2006-XX-XX_XXXXXXX.log:

2006-02-22 08:48:04 INFO:  22 Feb 06 08:48:04 core.ManageNotifyThread [ManageNotifyThread.createThread] Start creating thread
2006-02-22 08:48:04 INFO:  22 Feb 06 08:48:04 core.ManageNotifyThread [ManageNotifyThread.createThread] End of creating thread
2006-02-22 08:48:04 INFO:  22 Feb 06 08:48:04 core.NotifyThread [NotifyThread.run] Runs ...
2006-02-22 08:48:04 INFO:  22 Feb 06 08:48:04 core.NotifyThread [NotifyThread.run] Events.size: 5
2006-02-22 08:48:04 INFO:  22 Feb 06 08:48:04 core.NotifyThread [NotifyThread.run] Start calling webservice!
2006-02-22 08:48:04 INFO:  22 Feb 06 08:48:04 core.NotifyThread [NotifyThread.run] Webservice: Create Service!
2006-02-22 08:48:04 LOG:  server process (PID 1476) was terminated by signal 1
2006-02-22 08:48:04 LOG:  terminating any other active server processes
2006-02-22 08:48:04 WARNING:  terminating connection because of crash of another server process
2006-02-22 08:48:04 DETAIL:  The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
2006-02-22 08:48:04 HINT:  In a moment you should be able to reconnect to the database and repeat your command.
2006-02-22 08:48:04 LOG:  all server processes terminated; reinitializing
2006-02-22 08:48:04 LOG:  database system was interrupted at 2006-02-22 08:47:17 Westeurop?ische Normalzeit
2006-02-22 08:48:04 LOG:  checkpoint record is at 0/363D9BF0
2006-02-22 08:48:04 LOG:  redo record is at 0/363D9BF0; undo record is at 0/0; shutdown TRUE
2006-02-22 08:48:04 LOG:  next transaction ID: 13585; next OID: 256247
2006-02-22 08:48:04 LOG:  next MultiXactId: 1; next MultiXactOffset: 0
2006-02-22 08:48:04 LOG:  database system was not properly shut down; automatic recovery in progress
2006-02-22 08:48:04 LOG:  redo starts at 0/363D9C38
2006-02-22 08:48:04 LOG:  record with zero length at 0/3673EB88
2006-02-22 08:48:04 LOG:  redo done at 0/3673EB58
2006-02-22 08:48:05 LOG:  database system is ready
2006-02-22 08:48:05 LOG:  transaction ID wrap limit is 2147484148, limited by database "postgres"

hs_err_pid1476.log:

#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6dd02b5d, pid=1476, tid=1224
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0_04-b05 mixed mode)
# Problematic frame:
# C  [libpljava.dll+0x2b5d]
#

---------------  T H R E A D  ---------------

Current thread (0x024d2308):  JavaThread "NotifyThread" [_thread_in_native, id=1224]

siginfo: ExceptionCode=0xc0000005, reading address 0x00000004

Registers:
EAX=0x00000000, EBX=0x0880e7c8, ECX=0x0e482b00, EDX=0x0880eae8
ESP=0x0efbf680, EBP=0x0efbf680, ESI=0x0880e7c8, EDI=0x024d2308
EIP=0x6dd02b5d, EFLAGS=0x00010206

Top of Stack: (sp=0x0efbf680)
0x0efbf680:   0efbf6ac 025f826f 024d23c4 0efbf6b4
0x0efbf690:   0efbf690 00000000 0efbf6b8 0880eae8
0x0efbf6a0:   00000000 0880e7c8 0efbf6bc 0efbf6e0
0x0efbf6b0:   025f29fa 0880ea90 025f6453 08000001
0x0efbf6c0:   04b65230 0efbf6bc 0880e5ae 0efbf700
0x0efbf6d0:   0880eae8 00000000 0880e638 0efbf704
0x0efbf6e0:   0efbf720 025f29fa 00000000 00000000
0x0efbf6f0:   00000000 00000000 00000000 00000000 

Instructions: (pc=0x6dd02b5d)
0x6dd02b4d:   68 80 d1 6d 5d c2 08 00 55 89 e5 a1 c0 8e d1 6d
0x6dd02b5d:   8b 40 04 5d c2 08 00 55 89 e5 a1 c0 8e d1 6d c6 


Stack: [0x0ebc0000,0x0efc0000),  sp=0x0efbf680,  free space=4093k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [libpljava.dll+0x2b5d]
j  org.postgresql.pljava.jdbc.Invocation._getCurrent()Lorg/postgresql/pljava/jdbc/Invocation;+0
j  org.postgresql.pljava.jdbc.Invocation.current()Lorg/postgresql/pljava/jdbc/Invocation;+6
j  org.postgresql.pljava.jdbc.SPIConnection.prepareStatement(Ljava/lang/String;)Ljava/sql/PreparedStatement;+45
j  org.postgresql.pljava.sqlj.Loader.findClass(Ljava/lang/String;)Ljava/lang/Class;+52
j  java.lang.ClassLoader.loadClass(Ljava/lang/String;Z)Ljava/lang/Class;+43
j  java.lang.ClassLoader.loadClass(Ljava/lang/String;)Ljava/lang/Class;+3
j  java.lang.ClassLoader.loadClassInternal(Ljava/lang/String;)Ljava/lang/Class;+2
v  ~StubRoutines::call_stub
V  [jvm.dll+0x82696]
V  [jvm.dll+0xd6fd9]
V  [jvm.dll+0x82567]
V  [jvm.dll+0x8240f]
V  [jvm.dll+0xf3dde]
V  [jvm.dll+0xf3668]
V  [jvm.dll+0xf3152]
V  [jvm.dll+0xf305e]
V  [jvm.dll+0x5fdfd]
V  [jvm.dll+0x7d113]
j  core.NotifyThread.run()V+76
v  ~StubRoutines::call_stub
V  [jvm.dll+0x82696]
V  [jvm.dll+0xd6fd9]
V  [jvm.dll+0x82567]
V  [jvm.dll+0x822c4]
V  [jvm.dll+0x9d216]
V  [jvm.dll+0x101489]
V  [jvm.dll+0x101457]
C  [MSVCRT.dll+0x85bc]
C  [KERNEL32.dll+0xb388]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  org.postgresql.pljava.jdbc.Invocation._getCurrent()Lorg/postgresql/pljava/jdbc/Invocation;+0
j  org.postgresql.pljava.jdbc.Invocation.current()Lorg/postgresql/pljava/jdbc/Invocation;+6
j  org.postgresql.pljava.jdbc.SPIConnection.prepareStatement(Ljava/lang/String;)Ljava/sql/PreparedStatement;+45
j  org.postgresql.pljava.sqlj.Loader.findClass(Ljava/lang/String;)Ljava/lang/Class;+52
j  java.lang.ClassLoader.loadClass(Ljava/lang/String;Z)Ljava/lang/Class;+43
j  java.lang.ClassLoader.loadClass(Ljava/lang/String;)Ljava/lang/Class;+3
j  java.lang.ClassLoader.loadClassInternal(Ljava/lang/String;)Ljava/lang/Class;+2
v  ~StubRoutines::call_stub
j  core.NotifyThread.run()V+76
v  ~StubRoutines::call_stub

---------------  P R O C E S S  ---------------

Java Threads: ( => current thread )
=>0x024d2308 JavaThread "NotifyThread" [_thread_in_native, id=1224]
  0x015af648 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=300]
  0x0246a3c0 JavaThread "CompilerThread0" daemon [_thread_blocked, id=1908]
  0x015a93e8 JavaThread "Finalizer" daemon [_thread_blocked, id=1304]
  0x015a7ef8 JavaThread "Reference Handler" daemon [_thread_blocked, id=1916]
  0x01564d80 JavaThread "main" [_thread_in_native, id=1408]

Other Threads:
  0x02466e78 VMThread [id=1284]
  0x0246bb90 WatcherThread [id=332]

VM state:not at safepoint (normal execution)

VM Mutex/Monitor currently owned by a thread: None

Heap
 def new generation   total 576K, used 344K [0x04670000, 0x04710000, 0x04b50000)
  eden space 512K,  54% used [0x04670000, 0x046b62d0, 0x046f0000)
  from space 64K,  99% used [0x046f0000, 0x046ffff8, 0x04700000)
  to   space 64K,   0% used [0x04700000, 0x04700000, 0x04710000)
 tenured generation   total 1408K, used 726K [0x04b50000, 0x04cb0000, 0x08670000)
   the space 1408K,  51% used [0x04b50000, 0x04c05b98, 0x04c05c00, 0x04cb0000)
 compacting perm gen  total 8192K, used 3120K [0x08670000, 0x08e70000, 0x0c670000)
   the space 8192K,  38% used [0x08670000, 0x0897c130, 0x0897c200, 0x08e70000)
No shared spaces configured.

Dynamic libraries:
0x00400000 - 0x006f9000 	C:\Programme\PostgreSQL\8.1\bin\postgres.exe
0x77880000 - 0x77902000 	C:\WINNT\system32\ntdll.dll
0x79350000 - 0x793b5000 	C:\WINNT\system32\ADVAPI32.DLL
0x77e70000 - 0x77f30000 	C:\WINNT\system32\KERNEL32.dll
0x77d20000 - 0x77d98000 	C:\WINNT\system32\RPCRT4.dll
0x1c000000 - 0x1c006000 	C:\Programme\PostgreSQL\8.1\bin\comerr32.dll
0x78000000 - 0x78045000 	C:\WINNT\system32\MSVCRT.dll
0x77e00000 - 0x77e69000 	C:\WINNT\system32\USER32.dll
0x77f40000 - 0x77f7f000 	C:\WINNT\system32\GDI32.dll
0x10000000 - 0x10106000 	C:\Programme\PostgreSQL\8.1\bin\libeay32.dll
0x74fc0000 - 0x74fc9000 	C:\WINNT\system32\WSOCK32.dll
0x74fa0000 - 0x74fb4000 	C:\WINNT\system32\WS2_32.DLL
0x74f90000 - 0x74f98000 	C:\WINNT\system32\WS2HELP.DLL
0x00c00000 - 0x00c0d000 	C:\Programme\PostgreSQL\8.1\bin\libintl-2.dll
0x00c10000 - 0x00ceb000 	C:\Programme\PostgreSQL\8.1\bin\libiconv-2.dll
0x00cf0000 - 0x00d71000 	C:\Programme\PostgreSQL\8.1\bin\krb5_32.dll
0x719b0000 - 0x719b8000 	C:\WINNT\system32\SHFOLDER.DLL
0x00d80000 - 0x00db2000 	C:\Programme\PostgreSQL\8.1\bin\ssleay32.dll
0x74f40000 - 0x74f5e000 	C:\WINNT\system32\msafd.dll
0x74f80000 - 0x74f87000 	C:\WINNT\System32\wshtcpip.dll
0x6dd00000 - 0x6dedd000 	C:\Programme\PostgreSQL\8.1\lib\libpljava.dll
0x6d640000 - 0x6d7c9000 	C:\Programme\Java\jre1.5.0_04\bin\client\jvm.dll
0x77540000 - 0x77571000 	C:\WINNT\system32\WINMM.dll
0x6d280000 - 0x6d288000 	C:\Programme\Java\jre1.5.0_04\bin\hpi.dll
0x68f30000 - 0x68f3b000 	C:\WINNT\system32\PSAPI.DLL
0x6d610000 - 0x6d61c000 	C:\Programme\Java\jre1.5.0_04\bin\verify.dll
0x6d300000 - 0x6d31d000 	C:\Programme\Java\jre1.5.0_04\bin\java.dll
0x6d630000 - 0x6d63f000 	C:\Programme\Java\jre1.5.0_04\bin\zip.dll

VM Arguments:
jvm_args: -Dsqlj.defaultconnection=jdbc:default:connection vfprintf -Xrs
java_command: <unknown>

Environment Variables:
CLASSPATH=e:\sybase\ASEP\3pclass.zip;e:\sybase\ASEP\monclass.zip;
PATH=e:\Programme\sybase\JS-12_5\bin;e:\Programme\sybase\OCS-12_5\lib3p;e:\Programme\sybase\OCS-12_5\dll;e:\Programme\sybase\OCS-12_5\bin;c:\winnt\system32;E:\Programme\philips\speechpearl\bin;e:\sybase\ASEP;e:\sybase\OCS-12_0\dll;e:\sybase\OCS-12_0\bin;E:\Programme\philips\shared\bin;E:\Programme\philips\speechdetector\bin;C:\philips\speechpearl\bin;C:\philips\speechpearl\server\bin;e:\programme\philips\speechpearl\server\bin;e:\programme\philips\snmpagent\bin;C:\Programme\GNU\WinCvs 1.2;C:\Programme\Java\jre1.5.0_04\bin;C:\Programme\Java\jre1.5.0_04\bin\client;C:\Programme\Microsoft SQL Server\90\Tools\binn\;E:\Programme\Sun\jwsdp-2.0\jaxrpc\bin;E:\Programme\Sun\jwsdp-2.0\jwsdp-shared\bin;E:\Programme\Microsoft Visual Studio 8\SDK\v2.0\Bin;C:\WINNT\Microsoft.NET\Framework\v2.0.50727;C:\Programme\Java\jdk1.5.0_03\bin
USERNAME=postgres
OS=Windows_NT
PROCESSOR_IDENTIFIER=x86 Family 6 Model 8 Stepping 10, GenuineIntel



---------------  S Y S T E M  ---------------

OS: Windows 2000 Build 2195 Service Pack 4

CPU:total 1 family 6, cmov, cx8, fxsr, mmx, sse

Memory: 4k page, physical 522736k(136896k free), swap 1276844k(939860k free)

vm_info: Java HotSpot(TM) Client VM (1.5.0_04-b05) for windows-x86, built on Jun  3 2005 02:10:41 by "java_re" with MS VC++ 6.0



Maybe this helps...


______________________________________________________________
Verschicken Sie romantische, coole und witzige Bilder per SMS!
Jetzt bei WEB.DE FreeMail: http://f.web.de/?mc=021193





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* [Pljava-dev] Multithreading
@ 2006-02-22 08:21  
  parent: 
  0 siblings, 0 replies; 4+ messages in thread

From:  @ 2006-02-22 08:21 UTC (permalink / raw)

Patrick Peisker wrote:
> i use the PL/Java 1.1.0 released and here are some logs:
>
>   
You need to upgrade to 1.2.0 Once you do, your backend will be stable 
but you will run into the problems I mentioned before.

Regards,
Thomas Hallgren





^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2006-02-22 08:21 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-02-22 07:01 [Pljava-dev] Multithreading 
2006-02-22 07:49 ` 
2006-02-22 08:03 [Pljava-dev]  Multithreading 
2006-02-22 08:21 ` 

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox