Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Cancel long-running report
shamilton
If a BIRT report is running, taking a long time and consuming CPU/memory, we want the option to shut it down.<br />
<br />
I've tried running the report in a separate thread and calling IRunAndRenderTask.cancel(). However, the next thing I end up doing is wait for the child thread to complete, then I call IRunAndRenderTask.close() to ensure everything is cleaned up.<br />
<br />
When I call close(), I get an exception that looks like this:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>java.lang.IllegalStateException: Calling Context.exit without previous Context.enter
at org.mozilla.javascript.Context.exit(Context.java:452)
at org.eclipse.birt.report.engine.javascript.JavascriptEngine.close(JavascriptEngine.java:188)
at org.eclipse.birt.core.script.ScriptContext.close(ScriptContext.java:205)
at org.eclipse.birt.report.engine.executor.ExecutionContext.close(ExecutionContext.java:447)
at org.eclipse.birt.report.engine.api.impl.EngineTask.close(EngineTask.java:1506)
</pre>
<br />
Turns out this happens whether or not I call cancel. It *looks* to me like it might be a synchronization issue where the "state" of the task as it appears to the controller thread is out of sync with reality, but even if I synchronize around the close() call I get the same result. (I'm assuming, perhaps incorrectly?, that the synchronize will flush CPU caches and the like which would give me phantom/stale values for variables.)<br />
<br />
This leads me to the following questions:<br />
(1) Is this the way (or at least a safe way) to cancel a report - call the IRunAndRenderTask.cancel() from another thread? If not, what is the recommended way to do this?<br />
(2) Any clues as to why I can't close a task that is "started" in a child thread, even though the child thread has completed with no errors/exceptions?<br />
<br />
Thanks in advance,<br />
Scott
Find more posts tagged with
Comments
mwilliams
Hi Scott,
.cancel() stops the report, but doesn't stop the query. I guess it would finish executing and then it should be all stopped.
shamilton
As an update on the original post, I was able to get this working without this particular error by re-arranging the code a bit. (It now throws an IndexOutOfBoundsException but this actually appears harmless.)
Anyway, in answer to your reply, if you're saying that the execution of the query on the DB server won't be interrupted, that's true, but the result set caching code DOES seem to get interrupted, which is nice, because some reports might end up processing (in our case) millions of rows, which tends to take some time as the caching is processing all those rows.
shamilton
<blockquote class='ipsBlockquote' data-author="'shamilton'" data-cid="74008" data-time="1298816994" data-date="27 February 2011 - 07:29 AM"><p>...but the result set caching code DOES seem to get interrupted, which is nice, because some reports might end up processing (in our case) millions of rows, which tends to take some time as the caching is processing all those rows.<br /></p></blockquote>
Oops... on further investigation, it seems I was wrong. The caching continues even with the cancel having been called.<br />
<br />
It would be really, REALLY nice if calling cancel() would interrupt the result set caching too...<br />
<br />
I'll see if I can enter a bug report on this...
shamilton
Bugs added. One for this (#339446 -
https://bugs.eclipse.org/bugs/show_bug.cgi?id=339446)
and one for another memory leak bug that this revealed: #339770 -
https://bugs.eclipse.org/bugs/show_bug.cgi?id=339770