[Pljava-dev] postmaster hangs if JVM does not close nicely in windows

Lists: PostgreSQL : PostgreSQL 메일 링리스트 : 2011-11-04 이후 범퍼카 토토Dev 21:46
From: nathanegge at yahoo(dot)com (Nathan Egge)
To:
Subject: [Pljava-dev] postmaster hangs if JVM does not close nicely in windows
Date: 2011-11-04 12:40:42
Message-ID: 1320410442.74423.YahooMailNeo@web35706.mail.mud.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pljava-dev

I came across an interesting problem the other day using pl/Java. ?When I deployed my application in Linux everything worked just fine but when I ran it under Windows, every client connection would leave a postmaster process running, and shutting down the PostgreSQL 9.1 service would fail.

I finally traced it back to the fact that the services I was running in the JVM were not shutting down when the client disconnected (the finalize() method was not being called) and so the file resources they'd locked were not being released and the JVM process would not stop. ?This hung the postmaster process for each client connection (along with ~80MB of memory) and became a problem pretty quickly.

I ended up creating a patch for pl/Java that allowed me to get a Java event right before the JVM is destroyed (the onDestroyJavaVM event) which I could use to clean up and shutdown the services running, before pl/Java tried to stop the JVM. ?This may be useful to anyone else who is running complex Java services inside their database, so I have attached my patch to the issue Tracker here:

http://pgfoundry.org/tracker/index.php?func=detail&aid=1011111&group_id=1000038&atid=336

Nathan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pgfoundry.org/pipermail/pljava-dev/attachments/20111104/b1ea3aac/attachment.html>


From: johann at 2ndquadrant(dot)com (Johann 'Myrkraverk' Oskarsson)
To:
Subject: [Pljava-dev] postmaster hangs if JVM does not close nicely in windows
Date: 2011-11-04 21:46:46
Message-ID: x6r51nzhkp.fsf@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: PostgreSQL : PostgreSQL 메일 링리스트 : 2011-11-04 이후 범퍼카 토토Dev 21:46

Nathan Egge <nathanegge at yahoo.com> writes:

> I ended up creating a patch for pl/Java that allowed me to get a
> Java event right before the JVM is destroyed (the onDestroyJavaVM
> event) which I could use to clean up and shutdown the services
> running, before pl/Java tried to stop the JVM. This may be useful
> to anyone else who is running complex Java services inside their
> database, so I have attached my patch to the issue Tracker here:

Before applying that patch, I'd like to see it documented somewhere,
somehow, how to use it. Can you write a short description of this
facility?

> http://pgfoundry.org/tracker/index.php?func=detail&aid=1011111&group_id=
> 1000038&atid=336

--
Johann Oskarsson http://www.2ndquadrant.com/ |[]
PostgreSQL Development, 24x7 Support, Training and Services --+--
|
Blog: http://my.opera.com/myrkraverk/blog/