[Mulgara-general] Exception on startup

Alex Hall alexhall at revelytix.com
Mon Apr 28 18:52:32 UTC 2008


Paul Gearon wrote:
> On Apr 25, 2008, at 4:55 AM, Life is hard, and then you die wrote:
> 
>> I think the point Alex is trying to make is that mulgara never shuts
>> down cleanly, because A) there's no JVM shutdown hook registered
>> (Runtime.addShutdownHook()), and B) the EmbeddedMulgaraServer just
>> does a System.exit() without calling stop() on the server. I've
>> noticed this too: now that we've switched to RMI, none of our
>> resolvers ever get closed (before our servlet-wrapper called
>> SesionFactory.close() to clean up).
>>
>> I.e. mulgara always "crashes".
> 
> I see what you mean.
> 
> This is odd, as it USED to be done. Someone has removed it.  I did  
> notice that the shutdown output had changed, though I didn't realize  
> why.
> 
> Strangely, hitting ^C can often take a long time. I had always put  
> this down to the system flushing buffers. Does the GC cleanup get run  
> in the case of a break?

Most of my understanding of this aspect of the system comes from the 
Javadocs for the java.lang.Runtime class, which I would recommend 
skimming through.  Apparently, both ^C and System.exit() initiate the 
same JVM shutdown sequence, which does the following:

1.  Starts all shutdown hooks registered via the 
Runtime.addShutdownHook() method and allows them to run concurrently 
until the finish.

2.  If finalization-on-exit is enabled, then run all uninvoked 
finalizers.  This option is disabled by default, and I can't find 
anywhere that we are explicitly enabling it.  Furthermore, this option 
has been deprecated as it is "inherently unsafe".

So, if we're concerned about the server needing to release resources or 
flush buffers on shutdown, I would recommend adding a shutdown hook to 
perform the cleanup.  This would cover both invoking Mulgara with -x, or 
hitting ^C in the console -- in other words, all user-initiated shutdowns.

Alex



More information about the Mulgara-general mailing list