You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by Ian Emmons <ia...@emmons.mobi> on 2014/03/14 10:39:40 UTC

Stopping Fuseki and closing datasets

I am porting our triple store (Parliament) from Joseki to Fuseki, and I have a question.  How do I shut Fuseki down gracefully?  On *nix systems, of course, the JVM responds to the TERM signal, and so this works:

   kill `ps -ef | grep 'java.*fuseki' | grep -v grep | awk '{ print $2 }'`

However, there are two problems with this.  First, it doesn’t work on Windows, where the only similar actions are decidedly ungraceful.  This is a big problem, because Windows is important to our customers.

Second, even on *nix systems this doesn’t result in a graceful shutdown, because the close method on my DataSet is never called.  I realize that this is less of a problem for TDB datasets (because of transactions) and no problem for in-memory DataSets, but some stores (like ours) need this hook to ensure that pending file writes are flushed to disk.  And even for a transactional store like TDB, it seems to me that you would want to avoid unnecessary file recoveries.

I did try enabling the management server and issuing this command:

   http://localhost:58080/mgt?cmd=shutdown

This resulted in the following response, but no shutdown happened:

   Software:
     Fuseki 1.0.1
     TDB 1.0.1
     ARQ 2.11.1
     Apache Jena - Core 2.11.1

   Name = data
      Query           :: /data/query
      Update          :: /data/update
      Upload          :: /data/upload
      Graphs(Read)    :: /data/get
      Graphs(RW)      :: /data/data

So, how should I gracefully shut down Fuseki, and is there a way to ensure that my DataSet is closed?

Thanks,

Ian

Re: Stopping Fuseki and closing datasets

Posted by Andy Seaborne <an...@apache.org>.
On 14/03/14 09:39, Ian Emmons wrote:
> I am porting our triple store (Parliament) from Joseki to Fuseki,
> and  I have a question. How do I shut Fuseki down gracefully? On *nix
> systems, of course, the JVM responds to the TERM signal, and so this works:
>
>     kill `ps -ef | grep 'java.*fuseki' | grep -v grep | awk '{ print $2 }'`

fuseki stop

is more graceful and it knows the Fuseki process id.

But "kill -9" is fine.

> However, there are two problems with this. First, it doesn’t work on
 > Windows, where the only similar actions are decidedly ungraceful. This
> is a big problem, because Windows is important to our customers.

> Second, even on *nix systems this doesn’t result in a graceful
> shutdown, because the close method on my DataSet is never called. I
> realize that this is less of a problem for TDB datasets (because of
> transactions) and no problem for in-memory DataSets, but some stores
> (like ours) need this hook to ensure that pending file writes are
> flushed to disk. And even for a transactional store like TDB, it seems
> to me that you would want to avoid unnecessary file recoveries.

Any system needs to cope with unexpected crashes because they happen, 
for better or worse.  So it needs to cope with "kill -9" and if you 
believe that works, you might as well use it.  It's the principle of 
trusting the code.

(TDB file recovery happens on TDB start-up anyway because TDB is ACID.)

> I did try enabling the management server and issuing this command:
>
>     http://localhost:58080/mgt?cmd=shutdown

(Caution - old version)

An explicit graceful shutdown could be done but can't be guaranteed - 
it's not going to work for WAR deployment or init.d very well.  Or 
machine crashes, loss of network, accidental "upgrades" and all the 
other stuff that happen outside the JVM.

The new mgt subsystem architecture has been clarified and more amenable 
to extension.

	Andy

> This resulted in the following response, but no shutdown happened:
>
>     Software:
>       Fuseki 1.0.1
>       TDB 1.0.1
>       ARQ 2.11.1
>       Apache Jena - Core 2.11.1
>
>     Name = data
>        Query           :: /data/query
>        Update          :: /data/update
>        Upload          :: /data/upload
>        Graphs(Read)    :: /data/get
>        Graphs(RW)      :: /data/data
>
> So, how should I gracefully shut down Fuseki, and is there a way to ensure that my DataSet is closed?
>
> Thanks,
>
> Ian
>