how to kill a badly written query that's bringing the server to its knees

3,398 views
Skip to first unread message

Wes Freeman

unread,
Sep 24, 2012, 9:50:32 PM9/24/12
to ne...@googlegroups.com
I'm pretty new to neo4j, and in my experimentation the last few days I've run some pretty bad queries (with variable length relationships) that obviously got caught in cycles or huge relationship tangles. After waiting for several minutes with my CPU pegged and the service eating up all available RAM, I decided I'd rather just start fresh. The only way I could figure out how to do that was by actually killing the neo4j service process--just killing the shell wasn't good enough.

So, is there a better way to do that? Or, maybe an option to limit queries to a minute or something, before giving up on them?

I'm using 1.8.RC1.

Thanks,
Wes

Javier de la Rosa

unread,
Sep 24, 2012, 9:56:58 PM9/24/12
to ne...@googlegroups.com
On Mon, Sep 24, 2012 at 9:50 PM, Wes Freeman <freem...@gmail.com> wrote:
> Or, maybe an option to limit queries to a minute or something, before giving
> up on them?

+1. Or some kind of managing running queries in Neo4j Web Admin, like
if they were processes?


--
Javier de la Rosa
http://versae.es

Wes Freeman

unread,
Sep 24, 2012, 10:09:40 PM9/24/12
to ne...@googlegroups.com
On Mon, Sep 24, 2012 at 9:56 PM, Javier de la Rosa <ver...@gmail.com> wrote:
On Mon, Sep 24, 2012 at 9:50 PM, Wes Freeman <freem...@gmail.com> wrote:
> Or, maybe an option to limit queries to a minute or something, before giving
> up on them?

+1. Or some kind of managing running queries in Neo4j Web Admin, like
if they were processes?

 
Yeah, that would definitely work. I hated killing the service, because I had another graph building while I was messing around, so I had to start it over a couple of times--haven't built a way to resume yet.
 

Friso van Vollenhoven

unread,
Sep 25, 2012, 11:26:34 AM9/25/12
to ne...@googlegroups.com
It'd be handy to have something to kill running queries indeed. I run into this quite frequently when accidentally doing queries against densely connected nodes. My current solution is just killing the server and starting it up again (on *nix, this doesn't evict the page cache, so not all is lost), but I can image that's not a great solution for everyone...

Cheers,
Friso


--
 
 

Peter Neubauer

unread,
Sep 25, 2012, 11:33:47 AM9/25/12
to ne...@googlegroups.com
Actually,
there is a guard in the kernel that lets you time out queries, see
https://github.com/neo4j-contrib/rabbithole/blob/master/src/main/java/org/neo4j/community/console/GuardingRequestFilter.java

We want to expose this through Cypher as a kind of cancel hooks, but
this is what you can use for the time being.

Cheers,

/peter neubauer

Neo4j 1.8.RC1 "Vindeln Vy" -
http://blog.neo4j.org/2012/09/neo4j-18rc1-really-careful-ftw.html

G: neubauer.peter
S: peter.neubauer
P: +46 704 106975
L: http://www.linkedin.com/in/neubauer
T: @peterneubauer

Wanna learn something new? Come to @graphconnect.
> --
>
>

Javier de la Rosa

unread,
Sep 25, 2012, 12:00:04 PM9/25/12
to ne...@googlegroups.com
Any way to set this using REST or a config file?
> --

Michael Hunger

unread,
Sep 25, 2012, 12:12:35 PM9/25/12
to ne...@googlegroups.com
In server you can set a timeout using the server config:
org.neo4j.server.webserver.limit.executiontime=timeout in millis;

or by adding a header "max-execution-time" with a timeout in millis to your request

please try it and report how it goes.

In general we want to add a "cancel query/timout" feature to cypher and webadmin.

Thought that there was already an issue on github but couldn't find one. Could you please raise an issue there?

Thanks,

Michael


--
 
 

Wes Freeman

unread,
Sep 25, 2012, 1:07:52 PM9/25/12
to ne...@googlegroups.com

So, I added to neo4j-server.properties:
org.neo4j.server.webserver.limit.executiontime=1000

And got errors while starting: 
SEVERE:
java.lang.RuntimeException: Unable to use guard, you have to enable guard in neo4j.properties
   at org.neo4j.server.modules.RESTApiModule.setupRequestTimeLimit(RESTApiModule.java:108)
   at org.neo4j.server.modules.RESTApiModule.start(RESTApiModule.java:65)
   at org.neo4j.server.AbstractNeoServer.startModules(AbstractNeoServer.java:143)
   at org.neo4j.server.AbstractNeoServer.start(AbstractNeoServer.java:112)
   at org.neo4j.server.Bootstrapper.start(Bootstrapper.java:79)
   at org.neo4j.server.Bootstrapper.main(Bootstrapper.java:46)

So I tried to search about how to do that, and found some github merges mentioning that you should add this to the neo4j.properties file:
insert_guard=true

But, I still get the same error. Any hints?

Thanks,
Wes

--
 
 

Friso van Vollenhoven

unread,
Sep 25, 2012, 1:26:47 PM9/25/12
to ne...@googlegroups.com
Thanks. Didn't know about these configs. Will give it a go.

Friso


--
 
 

Peter Neubauer

unread,
Sep 25, 2012, 1:28:54 PM9/25/12
to ne...@googlegroups.com
The right name is execution_guard_enabled=true

Tracking down right now why this is not in the docs.

Cheers,

/peter neubauer

Neo4j 1.8.RC1 "Vindeln Vy" -
http://blog.neo4j.org/2012/09/neo4j-18rc1-really-careful-ftw.html

G: neubauer.peter
S: peter.neubauer
P: +46 704 106975
L: http://www.linkedin.com/in/neubauer
T: @peterneubauer

Wanna learn something new? Come to @graphconnect.


> --
>
>

Wes Freeman

unread,
Sep 25, 2012, 2:12:09 PM9/25/12
to ne...@googlegroups.com
Cool, I got it to work from my REST client.

Is there some way to get it to work for the neo4j-shell command line app, which I guess doesn't use REST? 

Thanks,
Wes

--



Peter Neubauer

unread,
Sep 25, 2012, 7:22:52 PM9/25/12
to ne...@googlegroups.com
Mmmh,
yes, that should work, too. For the server, the filter does the setup,
but if you use the neo4j-shell, you need to set it up there (if you
run it standalone). You could actually test it and maybe add the code?

Cheers,

/peter neubauer

Neo4j 1.8.RC1 "Vindeln Vy" -
http://blog.neo4j.org/2012/09/neo4j-18rc1-really-careful-ftw.html

G: neubauer.peter
S: peter.neubauer
P: +46 704 106975
L: http://www.linkedin.com/in/neubauer
T: @peterneubauer

Wanna learn something new? Come to @graphconnect.


> --
>
>

BtySgtMajor

unread,
Apr 18, 2014, 11:19:03 AM4/18/14
to ne...@googlegroups.com
Michael, with "execution_guard_enabled" set, does it use a default?  If so, is it set by org.neo4j.server.webserver.limit.executiontime?  Or something else?  Thanks.
Reply all
Reply to author
Forward
0 new messages