Multi-threading and Statement.cancel()

Attempting to execute queries on multiple threads (10 to 20) with the ability to cancel each Thread's unique Statement mid execution from a separate thread.

However, when sharing a single Connection among all threads for their Statement creation, a cancel() on one Statement will cause other thread's executeQuery() to throw a "Query execution was interrupted".

Switching to per thread Connections and a thread pool, the cancel() will sometimes fail with "Unknown thread id: xx". I'm assuming this occurs when a thread previously used to work with another connection attempts to cancel() another.

This had worked previously with MySql jdbc (and still does with MySql jdbc + MariaDb server).

The queries themselves are single table, limited/offset, selects. Where clauses would generally be related: query 1: like 'a%' query 2: like 'ab%' query 3: like 'abc%'

With each previous query being cancelled when a more specific query was available.

Any comments/suggestions appreciated. Thanks!

Answer Answered by Vladislav Vaintroub in this comment.

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


Comments loading...
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.