Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Abort executing query without setting "timeout" attribute in IBatis?

 
Vijay Kandaswamy
Greenhorn
Posts: 6
Hibernate Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A query is taking more than a minute to retrieve the data (Due to larger volume of data) from the database.
I need to stop its execution.
I know that, we can set "timeout" attribute in the select tag (For a single query alone) or "defaultStatementTimeout" attribute in settings tag (SqlMapConfig.xml - For all the query) to forcibly terminate the query in execution.

or


By doing the above configuration, IBatis will throw "User cancelled request" error and terminates the execution.
Do we have any other way to terminate the execution?

My Scenario:

When user requests for 3 years data, it takes more than a minute to fetch data from the database.
In the meantime, when the user requests for 1 day's data or sends a "cancel" request, I have to forcibly terminate the previous execution (3 years data retrieval) because it is affecting performance even with limited number of users.

NOTE
I didn't used any of the setting above.

Please provide me solution for this.
Thanks in advance .
 
Martin Vajsar
Sheriff
Pie
Posts: 3751
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

You should probably limit the number of concurrent requests for large amounts of data somehow (maybe down to one at a time?). Cancelling a request that has already processed substantial amount of data just because another request has arrived is a big waste of resources. The "small" requests should then be allowed alongside the "big" one(s), it will perhaps take longer, but so what - if someone needs to process such requests, the system must be sized up properly.

If you have a single application server, you could probably implement it easily there. If you have a more distributed application, you might use some database concurrency/locking mechanism for that.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic