Comments - Multi-threading and Statement.cancel()
Content reproduced on this site is the property of its respective owners,
and this content is not reviewed in advance by MariaDB. The views, information and opinions
expressed by this content do not necessarily represent those of MariaDB or any other party.
The mechanism used for cancel() is the same among all client drivers, so I really doubt it works with one driver and not with another one.
Drivers execute "kill query <connection_uid>", and the currently active query on this connection is interrupted. If you get "unknown thread", then the connection was already closed.
If you're getting "Query execution was interrupted" - yes it is what you should get after cancel() or "kill query" . Driver cannot pretend everything went OK :)
Ok, I noticed one minor bug in cancel() implementation (I filed in CONJ-58 and fixed already). Basically, even if statement was not executed, active query on current connection was interrupted. This could describe your multithreading scenario. However, the fix is still not 100% bulletproof ('kill query' is not entirely deterministic), but it should behave a bit better.
Cleaned up my test code. You were correct about the 'unknown thread' being from a closed connection. oops.
It sounds like you're describing what I'm hitting. Statement.cancel() on one thread interrupting a Statement.executeQuery() on a different Statement owned by a different thread.
I'll see if I can attach my test code. I do get different behavior based on the jdbc driver included. Seems like Connection wide cancellation vs Statement cancellation.
It is the only thing what server can do - connection wide cancellation with "kill query <connection>". Statement cancellation can only be emulated on client by checking if thus statement is being executed currently
Fair enough. Thanks for your time.