Fixed a bug in cancel_query; it was stupidly trying to establish a lock on the active session, defeating its purpose