4

Most databases provide a mechanism for users to list running queries and cancel them if required. This is particularly useful is terminating queries that take a lot of time. For example, in MySQL you woul do something like this:

mysql>show processlist;
mysql> kill <pid>;

How can I do Something similar on a gremlin server? So far, the only knob available is the scriptEvaluationTimeout in the yaml configuration, which lets you terminate your request on timeout. I'm interested in an API that can list all running queries and an API that can let me delete queries by ID. If that's not supported already, does tinkerpop have plans to support it in newer versions? SOmething like:

g.query()
g.query('123')
g.query('123').cancel()
The-Big-K
  • 2,672
  • 16
  • 35
  • 4
    This is a perfectly fine question for those who know the TinkerPop ecosystem to which this question is addressed. – stephen mallette Oct 30 '18 at 00:25
  • 1
    I am inclined to agree with Stephen, the question is can I cancel a running query for which Stephen then provides a perfectly reasonable answer so why down vote the question and put on hold? – default_avatar Oct 30 '18 at 10:47

1 Answers1

5

There is nothing in Gremlin Server that will list running queries. The server log configured with with a greater verbosity level might give you some hints, but that's not really a great workaround I guess. Some graph systems will have the native ability to provide you that information - i.e. "a slow query log" sort of functionality but it is not something that TinkerPop exposes to you.

As for cancellation, according to standard TinkerPop semantics a Traversal should respect a request for interruption on a thread. These semantics are enforced by the TinkerPop process test suite. That said, it is still up to the graph provider to properly allow for that behavior. Gremlin Server will attempt to interrupt bytecode or script based traversals that exceed the scriptEvaluationTimeout configuration on the server or the override for that value provided per-request. Setting those timeouts appropriately and using a provider that respects the TinkerPop semantics for cancellation is the best defense you have for a run-away traversal. Note that graph providers that simply implement the Gremlin Server protocols (but may not use Gremlin Server itself) could have different timeout control options.

We definitely improved traversal cancellation from TinkerPop 2.x in our current version at 3.x - hopefully for 4.x we can really nail it perfectly.

stephen mallette
  • 45,298
  • 5
  • 67
  • 135
  • Thanks Stephen. Can we get something like g.query('123').cancel() and similar APIs in an upcoming version? Its best if we can standardize this before vendors build something custom. – The-Big-K Oct 30 '18 at 15:56
  • I'm not against a proposal for a cancellation option. Such proposals and following discussions belong on the dev mailing list: https://lists.apache.org/list.html?dev@tinkerpop.apache.org – stephen mallette Nov 01 '18 at 10:02
  • Will do! Thanks. – The-Big-K Nov 03 '18 at 21:27