Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion 'Non clean shutdown detected' even though shutdown() method gets called

Received: by 10.59.0.194 with SMTP id ba2mr4965547ved.19.1351002257820;
        Tue, 23 Oct 2012 07:24:17 -0700 (PDT)
X-BeenThere: neo4j@googlegroups.com
Received: by 10.52.141.116 with SMTP id rn20ls621524vdb.5.gmail; Tue, 23 Oct
 2012 07:24:16 -0700 (PDT)
Received: by 10.224.97.199 with SMTP id m7mr2876033qan.5.1351002256075;
        Tue, 23 Oct 2012 07:24:16 -0700 (PDT)
Received: by 10.224.97.199 with SMTP id m7mr2876032qan.5.1351002256055;
        Tue, 23 Oct 2012 07:24:16 -0700 (PDT)
Return-Path: <wujek.sru...@gmail.com>
Received: from mail-qa0-f47.google.com (mail-qa0-f47.google.com [209.85.216.47])
        by gmr-mx.google.com with ESMTPS id a27si591373qck.3.2012.10.23.07.24.16
        (version=TLSv1/SSLv3 cipher=OTHER);
        Tue, 23 Oct 2012 07:24:16 -0700 (PDT)
Received-SPF: pass (google.com: domain of wujek.sru...@gmail.com designates 209.85.216.47 as permitted sender) client-ip=209.85.216.47;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of wujek.sru...@gmail.com designates 209.85.216.47 as permitted sender) smtp.mail=wujek.sru...@gmail.com; dkim=pass header...@gmail.com
Received: by mail-qa0-f47.google.com with SMTP id i29so1971181qaf.20
        for <neo4j@googlegroups.com>; Tue, 23 Oct 2012 07:24:16 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=mime-version:in-reply-to:references:date:message-id:subject:from:to
         :content-type;
        bh=wmghiadYEZYdQ7ig/3kD0Ocy0x8lzz847QvzSD0iBns=;
        b=L2XRQitSt9xbbyIQeO/40rTTNpJRxy84mmF0EHUodyA8Rh1+DL50Sr2nh59gQnVaro
         zCJuLXhfvoznxguOBWvZeXF+bhh4x+z7iGnTUklzW0Nwj7BnwMadXpXm+Wi9Z/rVjRld
         SrodEd8Lobk+z0Q1nvGZahzH6dzEamiY65OUKCbwPgJFiFUSLaON+aFFmuC11yL0LTft
         q826fLPP4peAbmZSV1V9y2VzEEh4fvU2dcUy1NVuPCa46gf9ssqpw5nsiFcO+sQMEUGE
         SgXFDphW403J4zYdkRkgZv+bC7C55DX6e5CfKFWUWkabfmmVPuYE1g/+Oayx9JUcgUPC
         LXpA==
MIME-Version: 1.0
Received: by 10.229.196.30 with SMTP id ee30mr1435269qcb.125.1351002255847;
 Tue, 23 Oct 2012 07:24:15 -0700 (PDT)
Received: by 10.229.72.12 with HTTP; Tue, 23 Oct 2012 07:24:15 -0700 (PDT)
In-Reply-To: <E45669A2-83B7-45FD-9818-8758A1EAF...@neotechnology.com>
References: <4393d971-0cb4-4651-871e-7ddcc2036e4a@googlegroups.com>
	<CAEwL3ekZG08kQ0Wq36KHcMwkSQW-cLo+3yHj8DLVPnMK4a5...@mail.gmail.com>
	<CAAuGTBhszJa+U+mLZJ2oJrDcwfo8bYgqjYL0fEW4=RhqeM+...@mail.gmail.com>
	<882582D0-5530-40D4-B7C4-83FE1465B...@neotechnology.com>
	<CAAuGTBgruj5BM940o62TH4m0a1oH-MaYD=2gZvM=JuvUCnR...@mail.gmail.com>
	<CAAuGTBgQ2x3zP9pT7UcDS4jLANJTzaHixUQR6jUHbTuqj=D...@mail.gmail.com>
	<47028609-1be6-48fc-b81e-156b3ddbab5b@googlegroups.com>
	<79095467-2EC3-48F4-81E9-1BA10E44B...@neotechnology.com>
	<CAAuGTBgqf=9s1WM3HL84WHioK6BK8bEkTbvXju0jVLLxNTE...@mail.gmail.com>
	<bb3ce032-d65c-4baa-b13a-3f47c4fb6c66@googlegroups.com>
	<E45669A2-83B7-45FD-9818-8758A1EAF...@neotechnology.com>
Date: Tue, 23 Oct 2012 16:24:15 +0200
Message-ID: <CAAuGTBjR1rwsYAaMJ8YHvzv=dSoEuiKpW9HktHiX5OH51=X...@mail.gmail.com>
Subject: Re: [Neo4j] 'Non clean shutdown detected' even though shutdown()
 method gets called
From: Wujek Srujek <wujek.sru...@gmail.com>
To: neo4j@googlegroups.com
Content-Type: multipart/alternative; boundary=0016369209fc8cf1e404ccbab964

--0016369209fc8cf1e404ccbab964
Content-Type: text/plain; charset=ISO-8859-1

Correct, but this would mean I need to 'patch' all tomcats that my
application is supposed to run on, which is not a good idea I think -
first, I can't just hand a working war; second - a memleak, see below. I
will just do it 'the right way', i.e., shutdown the database in a
ServletContextListener. It will require slight redesign but no biggie. I
had hoped I could do it with the shutdown hook, as I could just register
the hook in the guice module and it would work no matter how my backend
services are used (webapp, ejb, JavaSE app, whatever), but this just
doesn't work.

Actually, this shutdown hook idea for a webapp that I had and tried to
implement is completely broken - suppose it works; if my application is
undeployed from the server, but the server itself is not shut down, the
database will not be shut down until the server JVM goes down - as I have
no ServletContextListener.contextDestroyed. Nice. I've just created a nasty
memory leak, as as said, the shutdown hook thread is a GC root, it keeps a
reference to the WebappCL that loaded it, which in turn keeps references to
all classes that it ever loaded. Redeploy the app a few times and it will
result in a OOME: PermSpace rather sooner than later. Stupid me.

I actually debugged it a little more with tomcat sources and all things
said previously are correct - when tomcat stops, it stops all internal
services, and in the depths, each WebappCL is also a service, and all its
fields get nulled out and eventually the CL itself gets nulled out.
However, in my 'clever' idea, this nulling out doesn't help the GC. I
really hope others are smarter and don't try to do this, and if they do, I
hope this thread will come in handy...

wujek


On Tue, Oct 23, 2012 at 3:41 PM, Michael Hunger <
michael.hun...@neotechnology.com> wrote:

> Or you have to make the neo4j dependencies available to the tomcat
> root/boot classpath.
>
> Michael
>
> Am 23.10.2012 um 14:55 schrieb wujek <wujek.sru...@gmail.com>:
>
> > Ok, so I did some more debugging and here is what I found out - when the
> shutdown hook is executed, the tomcat's WebAppClassLoader for my webapp
> still exists (as the class containing the code being called was loaded with
> it and keeps a hard reference, and live threads, what the hook really is,
> are GC-roots so are not collectable), but all its fields (most importantly
> in this case, repositoryUrls - this is where URLs for jars form WEB-INF/lib
> are kept) are empty, contrary to when I debug the application while tomcat
> runs normally. This means, IndexReference is probably the first class that
> is in WEB-INF/lib that is used during shutdown that hasn't been loaded for
> the application yet - and the WebAppClassLoader tries to load it, and
> fails, tries to load the ThrowableProxy to log the exception, and it also
> fails - the webapp CL is empty and cannot load anything. It's parent is
> StandardClassLoader which has the tomcat/lib jars, then there is the system
> class loader, extensions CL, and bootstrap - none of these can load the
> classes and hence the failure.
> > When I force loading this class with
> Class.forName("org.neo4j.index.impl.lucene.IndexReference"), which uses the
> caller CL, which is the WebAppClassLoader, all works as expected,
> >
> > This basically means that the shutdown hook trick is not usable for web
> applications, at least on tomcat 7.0.x.
> >
> > --
> >
> >
>
> --
>
>
>

--0016369209fc8cf1e404ccbab964
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Correct, but this would mean I need to &#39;patch&#39; all tomcats that my =
application is supposed to run on, which is not a good idea I think - first=
, I can&#39;t just hand a working war; second - a memleak, see below. I wil=
l just do it &#39;the right way&#39;, i.e., shutdown the database in a Serv=
letContextListener. It will require slight redesign but no biggie. I had ho=
ped I could do it with the shutdown hook, as I could just register the hook=
 in the guice module and it would work no matter how my backend services ar=
e used (webapp, ejb, JavaSE app, whatever), but this just doesn&#39;t work.=
<div>
<br></div><div>Actually, this shutdown hook idea for a webapp that I had an=
d tried to implement is completely broken - suppose it works; if my applica=
tion is undeployed from the server, but the server itself is not shut down,=
 the database will not be shut down until the server JVM goes down - as I h=
ave no ServletContextListener.contextDestroyed. Nice. I&#39;ve just created=
 a nasty memory leak, as as said, the shutdown hook thread is a GC root, it=
 keeps a reference to the WebappCL that loaded it, which in turn keeps refe=
rences to all classes that it ever loaded. Redeploy the app a few times and=
 it will result in a OOME: PermSpace rather sooner than later. Stupid me.</=
div>
<div><br></div><div>I actually debugged it a little more with tomcat source=
s and all things said previously are correct - when tomcat stops, it stops =
all internal services, and in the depths, each WebappCL is also a service, =
and all its fields get nulled out and eventually the CL itself gets nulled =
out. However, in my &#39;clever&#39; idea, this nulling out doesn&#39;t hel=
p the GC. I really hope others are smarter and don&#39;t try to do this, an=
d if they do, I hope this thread will come in handy...</div>
<div><br></div><div>wujek<br><div><br><br><div class=3D"gmail_quote">On Tue=
, Oct 23, 2012 at 3:41 PM, Michael Hunger <span dir=3D"ltr">&lt;<a href=3D"=
mailto:michael.hun...@neotechnology.com" target=3D"_blank">michael.hunger@n=
eotechnology.com</a>&gt;</span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">Or you have to make the neo4j dependencies a=
vailable to the tomcat root/boot classpath.<br>
<br>
Michael<br>
<br>
Am 23.10.2012 um 14:55 schrieb wujek &lt;<a href=3D"mailto:wujek.srujek@gma=
il.com">wujek.sru...@gmail.com</a>&gt;:<br>
<div><div class=3D"h5"><br>
&gt; Ok, so I did some more debugging and here is what I found out - when t=
he shutdown hook is executed, the tomcat&#39;s WebAppClassLoader for my web=
app still exists (as the class containing the code being called was loaded =
with it and keeps a hard reference, and live threads, what the hook really =
is, are GC-roots so are not collectable), but all its fields (most importan=
tly in this case, repositoryUrls - this is where URLs for jars form WEB-INF=
/lib are kept) are empty, contrary to when I debug the application while to=
mcat runs normally. This means, IndexReference is probably the first class =
that is in WEB-INF/lib that is used during shutdown that hasn&#39;t been lo=
aded for the application yet - and the WebAppClassLoader tries to load it, =
and fails, tries to load the ThrowableProxy to log the exception, and it al=
so fails - the webapp CL is empty and cannot load anything. It&#39;s parent=
 is StandardClassLoader which has the tomcat/lib jars, then there is the sy=
stem class loader, extensions CL, and bootstrap - none of these can load th=
e classes and hence the failure.<br>

&gt; When I force loading this class with Class.forName(&quot;org.neo4j.ind=
ex.impl.lucene.IndexReference&quot;), which uses the caller CL, which is th=
e WebAppClassLoader, all works as expected,<br>
&gt;<br>
&gt; This basically means that the shutdown hook trick is not usable for we=
b applications, at least on tomcat 7.0.x.<br>
&gt;<br>
&gt; --<br>
&gt;<br>
&gt;<br>
<br>
</div></div>--<br>
<br>
<br>
</blockquote></div><br></div></div>

--0016369209fc8cf1e404ccbab964--