Launch VA & edit query (against MS SQL Server)
WAITFOR DELAY '00:0:15' select * from Person.[Address]
Now click Save. A pop-up dialog will appear stating executing query. Now click the Cancel button in the pop-up. You'll be returned to the Edit Query dialog w/ all buttons disabled. You have to wait for the background query to finish execution prior to the buttons being enabled again.
See attached screenshots:
When the user clicks the Save button in the Edit Query dialog, BIExecuteQuery.execute() is invoked to execute the query. At this time a Progress dialog is displayed. When the user clicks the Cancel button in dialog, the BIFileProgressDialog.onCancel() method gets invoked, which in turn will invoke the interrupt() method on the query execution thread. For some reason, this execute thread did not get interrupted, but continued executing the query.
On the Query Analyzer side, the query execution is handled by QueryThread.run(), which responds successfully to the interrupt request.
So the real fix is to figure out why the BIExecuteQuery.execute() thread did not respond to the interrupt request.
Once we get the 'real fix', we should also enhance the VA status dialog to report what is occurring, similar to executing a query in query analyzer: Executing..., retrieving rows..., va processing, etc
Once we get the 'real fix', we should also enhance the VA status dialog to report what is occurring, similar to executing a query in query analyzer: Executing..., retrieving rows..., va processing, etc
First, here is how Query Analyzer cancels query execution.
- QueryPanel creates a QueryThread.
- QueryThread.run calls AFScriptContext.executeScriptStatements.
- AFScriptContext.executeScriptStatements calls Statement.execute to tell the JDBC Driver to execute the SQL statement.
- When the Stop button is clicked, QueryPanel.cancelQuery() is called.
- QueryPanel.cancelQuery checks if the QueryThread is still there. If it is, it calls QueryThread.cancelQuery.
- QueryThread.cancelQuery calls AFScriptContext.cancelQuery.
- AFScriptContext.cancelQuery calls Statement.cancel to tell the JDBC Driver to stop the SQL statement.
I set a breakpoint at the following calls and then go through the scenario using VA's Edit Query Dialog.
- AFScriptContext.executeScriptStatements
- AFScriptContext.cancelQuery
- WrappedStatement.execute
- WrappedStatement.cancel
When clicking Save, the SQL query is executed in a background thread. AFScriptContext.executeScriptStatements and WrappedStatement.execute get called. Then the progress dialog pops up. When clicking Cancel, the background thread is interrupted, but AFScriptContext.cancelQuery and WrappedStatement.cancel does NOT get called.
When the background thread gets interrupted, all it does is that it dismisses the progress dialog. With the current implementation, when the progress dialog is dismissed and focus goes back to the Edit Query Dialog, the buttons are still disabled because it is still waiting for the query results.
I also checked issue #13170 and looked at the code changes for that issue. AFScriptContext.cancelQuery is not called.
First, here is how Query Analyzer cancels query execution.
- QueryPanel creates a QueryThread.
- QueryThread.run calls AFScriptContext.executeScriptStatements.
- AFScriptContext.executeScriptStatements calls Statement.execute to tell the JDBC Driver to execute the SQL statement.
- When the Stop button is clicked, QueryPanel.cancelQuery() is called.
- QueryPanel.cancelQuery checks if the QueryThread is still there. If it is, it calls QueryThread.cancelQuery.
- QueryThread.cancelQuery calls AFScriptContext.cancelQuery.
- AFScriptContext.cancelQuery calls Statement.cancel to tell the JDBC Driver to stop the SQL statement.
I set a breakpoint at the following calls and then go through the scenario using VA's Edit Query Dialog.
- AFScriptContext.executeScriptStatements
- AFScriptContext.cancelQuery
- WrappedStatement.execute
- WrappedStatement.cancel
When clicking Save, the SQL query is executed in a background thread. AFScriptContext.executeScriptStatements and WrappedStatement.execute get called. Then the progress dialog pops up. When clicking Cancel, the background thread is interrupted, but AFScriptContext.cancelQuery and WrappedStatement.cancel does NOT get called.
When the background thread gets interrupted, all it does is that it dismisses the progress dialog. With the current implementation, when the progress dialog is dismissed and focus goes back to the Edit Query Dialog, the buttons are still disabled because it is still waiting for the query results.
I also checked issue #13170 and looked at the code changes for that issue. AFScriptContext.cancelQuery is not called.
Verified and Closed in ADS 18.0.8-7 and ADS 19-dev-21
- When user clicks on Cancel button in the executing query pop-up of Edit query dialog, control returns to the Edit Query dialog and all buttons in dialog gets ENABLED immediately.
Verified and Closed in ADS 18.0.8-7 and ADS 19-dev-21
- When user clicks on Cancel button in the executing query pop-up of Edit query dialog, control returns to the Edit Query dialog and all buttons in dialog gets ENABLED immediately.
Issue #14830 |
Closed |
Fixed |
Resolved |
Completion |
No due date |
Fixed Build 18.0.8-5 |
No time estimate |
1 issue link |
relates to #13170
Issue #13170Cancel option when query is executed via parameterized query |
When the user clicks the Save button in the Edit Query dialog, BIExecuteQuery.execute() is invoked to execute the query. At this time a Progress dialog is displayed. When the user clicks the Cancel button in dialog, the BIFileProgressDialog.onCancel() method gets invoked, which in turn will invoke the interrupt() method on the query execution thread. For some reason, this execute thread did not get interrupted, but continued executing the query.
On the Query Analyzer side, the query execution is handled by QueryThread.run(), which responds successfully to the interrupt request.
So the real fix is to figure out why the BIExecuteQuery.execute() thread did not respond to the interrupt request.