[Mondrian] Having some problems with query cancel

Pedro Salgueiro pedro.salgueiro at cortex-intelligence.com
Mon Nov 18 15:25:57 EST 2013


Hi,

I have been playing with the method Statement.cancel() in order to cancel
some long running queries on user demand, which is not revealing to be an
easy task.

Although in some queries, the cancel() method seems to be working perfectly
and an exception is thrown when the query is canceled, as it's supposed to
be, on other queries, nothing happens.
After some debugging, I reached to the conclusion that when a query
includes many specific members, we are not able to cancel it.

If we execute the following query, we are able to cancel it with no
problems.

WITH
> MEMBER [Measures].[Sleepy]
> AS SleepUdf([Measures].[Unit Sales])

SELECT
> [Product].[Product Family].Members ON 0,
> [Measures].[Unit Sales],[Measures].[Sleepy] ON 1
> FROM [Sales]



On the other hand, if we execute the following query with about 30 or 40
members, we are no longer able to cancel it:

WITH
> MEMBER [Measures].[Sleepy]
> AS SleepUdf([Measures].[Unit Sales])

SELECT
> {[Product].[Product Family].[Member 1], [Product].[Product Family].[Member
> 1], ..., [Product].[Product Family].[Member n]} ON 0,

[Measures].[Unit Sales],[Measures].[Sleepy] ON 1
> FROM [Sales]


It's worth point out that SleepUdf is a user defined function which uses a
Thread.sleep(), forcing the queries to take longer to execute, inspired by
Mondrian's BasicQueryTest.java. This way we are able to properly test if
the cancel is working.

I was looking at the cancel implementation in the MondrianOlap4jStatement
class, and if the openCellSet is null, nothing is done. What are the
conditions that would lead to a null openCellSet?

The queries that we are not being able to cancel produces a large number of
SQL queries, and the cancel() method is executed while these SQL queries
are being executed. Is it possible that we are trying to cancel the query
when it's not ready to be stopped? Or maybethe cancel method encounters the
query in a state that is not possible to be stopped yet, maybe between the
execution of two SQL queries?

In situations like this, is there any other approach to cancel the query?
Do you know any easy solution to solve this problem?

Any help will be greatly appreciated,
Pedro Salgueiro
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.pentaho.org/pipermail/mondrian/attachments/20131118/d4e7105d/attachment.html 


More information about the Mondrian mailing list