The-Big-K
The-Big-K

Reputation: 2830

How do I list running gremlin queries? How can I cancel slow or long running queries?

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()

Upvotes: 5

Views: 825

Answers (1)

stephen mallette
stephen mallette

Reputation: 46226

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.

Upvotes: 6

Related Questions