Cancel/kill query


#1

Hello, how do I cancel a query running in SciDB?

I looked through the documentation but could not find anything.

Thanks,

Patrick


#2

Err, i usually use ‘ctrl+z’ and then restart the scidb cluster.
Does anyone have a better solution?


#3

I don’t see it on the AFL documentation pages, but there is an AFL operator called cancel() that will do this. It takes a query ID, which can be obtained, e.g., by the list(‘queries’)

SciDB-Py v14.7 will cancel the current query if you hit ctrl+c. I believe SciDBR does something similar.


#4

if you’re stuck at the client, then how can you use the cancel() function? :wink: just insteresting


#5

Yeah, you have to call that function from another client connection :smile: I don’t know if SciDB automatically cancels a query if you kill the client process


#6

i tried some times,but some time it stuck and it doesn’t stop even when you use ctrl+z :smile: Interesting!


#7

Caution

Previous responses on this thread seem outdated

  • e.g. there are mechanisms in the SciDB-R and SciDB-Py clients by which a “unresponsive” query can be canceled [link, link etc.]).

Demo using iquery

However the original question is relevant – “how to kill / cancel a query” e.g. @dahaynes asked about this at this post.

Here is a demo using the command line iquery client:

### TERMINAL 1
# Run a long-running query 
# Below a sleep command for 200 seconds is issued
iquery -aq "build(<val:double>[i=0:0], sleep(200))"

### TERMINAL 2
# From another terminal
iquery -aq "list('queries')"
# {inst,n} query_id,coordinator,query_string,creation_time,error_code,error,idle,user_id,user
# {0,0} '0.1533746454670977500',0,'build(<val:double>[i=0:0], sleep(200))','2018-08-08 16:40:54',0,'Success',false,1,'scidbadmin'
# {0,1} '0.1533746456656663900',0,'list(\'queries\')','2018-08-08 16:40:56',0,'Success',false,1,'scidbadmin'
# {1,0} '0.1533746454670977500',0,'','2018-08-08 16:40:54',0,'Success',false,1,'scidbadmin'
# {1,1} '0.1533746456656663900',0,'','2018-08-08 16:40:56',0,'Success',false,1,'scidbadmin'

### TERMINAL 2
# Now you can cancel the unresponsive query
iquery -aq "cancel('0.1533746454670977500')"
# Query was executed successfully

### TERMINAL 1
# The following shows up on the original terminal
iquery -aq "build(<val:double>[i=0:0], sleep(200))"
# SystemException in file: src/query/Query.cpp function: handleAbort line: 644
# Error id: scidb::SCIDB_SE_QPROC::SCIDB_LE_QUERY_CANCELLED
# Error description: Query processor error. Query 0.1533746454670977500 was cancelled.
# Failed query id: 0.1533746454670977500

Redimension, store large array