Cancellation of parallel queries on server [message #916005] |
Tue, 18 September 2012 11:47 |
Samuel Messages: 22 Registered: January 2012 |
Junior Member |
|
|
There is a mechanism to cancel long running statements on the server.
The mechanism works as follows:
- Each SQL statement is put into a map of currently running statements before it is executed.
- After the execution, the statement is removed from the map.
The client can request a cancel of the currently executing server calls.
This can be done by clicking the cancel button on the bottom right of the application window that appears e.g. when a search is executed.
This works as long as the server call does not open its own threads.
However, when the server call opens its own threads (e.g. for parallel execution of database queries), the mechanism no longer works.
In our application, a server call opens own threads. Each thread executes a query as can be seen in the following code snippet:
Object[][] searchResult = ServerUtility.doScoutTransaction(
new RunnableWithException<Object[][]>() {
public Object[][] run() throws Throwable {
return execSearch(searchFormData);
}
},
serverSession.getClass(),
new Holder<IServerSession>(IServerSession.class,serverSession),
null
);
What is the recommended way to execute "interruptible" parallel queries on the server?
[Updated on: Tue, 18 September 2012 11:47] Report message to a moderator
|
|
|
|
Re: Cancellation of parallel queries on server [message #940366 is a reply to message #916022] |
Thu, 11 October 2012 15:14 |
Ken Lee Messages: 97 Registered: March 2012 |
Member |
|
|
Hi Samuel,
I had a deeper look into the Scout code.
In the general case where the client application makes a server call, a server job is created with a new transaction.
This transaction will be registered in the ActiveTransactionRegistry that is a map containing the service request sequence number as key and the transaction object as value.
If the client cancels its query execution, the ServerProcessingCancelService is used where the client passes the previous service request sequence number as a parameter.
The server fetches the transaction object in the ActiveTransactionRegistry and then executes the cancel operation on it.
For your use case, the following would be required to enable cancellation of multiple server jobs:
- Each server job that is created inside the service call should have the same transaction sequence number. That could be done be calling the setter setTransactionSequence before the "child server job" is scheduled.
- When a child server job gets started, a new transaction object is created automatically and registered in the ActiveTransactionRegistry.
- ActiveTransactionRegistry must be able to map a transaction sequence number to a list of transaction objects.
This however is currently not possible, since a the ActiveTransactionRegistry can only map one sequence number to a transaction object.
In summary, cancellation of multiple queries is currently not possible. But it could be done by extending the ActiveTransactionRegistry.
Feel free to create an enhancement ticket for Scout in Bugzilla
[Updated on: Thu, 11 October 2012 15:15] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03192 seconds