db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kristian Waagan <Kristian.Waa...@Sun.COM>
Subject Re: cancel a running query?
Date Fri, 10 Oct 2008 13:38:01 GMT
Rick Hillegas wrote:
> Hi Dirk,
> Yes, Derby does support Statement.setQueryTimeout(), at least as 
> verified by the Derby regression test 
> org.apache.derbyTesting.functionTests.tests.lang.SetQueryTimeoutTest. 
> That's a good defense if you suspect in advance that your queries may 
> ramble on. It leaves the lingering issue of how to cancel a runaway 
> query that you (or someone else) didn't limit before the query started.

It should be noted though, that your mileage may vary with 
setQueryTimeout. I assume that mechanism requires the engine to check a 
flag to see if it should abort, and if the code is "stuck" in an area 
where there are no such checks you might have to wait longer than the 
specified timeout value.
If anyone has been using it, it would be nice to get some feedback on 
how well it is working/behaving.

Is it possible to use the same machinery to add support for timing out a 
running transaction?
Is this something that would be needed by many users?
I suppose the client (dba, user etc) would normally have an idea whether 
the transaction/query will finish in a few seconds or a few days before 
issuing it.


> Hope this helps,
> -Rick
> Dirk Flachbart wrote:
>> Doesn't Derby support Statement.setQueryTimeout() ?
>> Dirk
>> derby@segel.com <mailto:derby@segel.com> wrote:
>>> A rollback doesn't "cancel" a query. Meaning that you can't stop the 
>>> query
>>> until it completes.
>>> The rollback will reverse the results of a transaction after the SQL
>>> statement completes. A query is unaffected because its not a SQL 
>>> statement
>>> that changes the database. (query == SELECT, other statements 
>>> INSERT, etc ... do change the data.)
>>> So if you start  a query, there isn't a way to have some sort of query
>>> timeout or call to prematurely end the query. (Perhaps you need to 
>>> consider
>>> threading your app...)
>>> HTH
>>> -Mike
>>>> -----Original Message-----
>>>> From: Dag.Wanvik@Sun.COM <mailto:Dag.Wanvik@Sun.COM> 
>>>> [mailto:Dag.Wanvik@Sun.COM]
>>>> Sent: Thursday, October 09, 2008 9:09 PM
>>>> To: Derby Discussion
>>>> Subject: Re: cancel a running query?
>>>> Rick Hillegas <Richard.Hillegas@Sun.COM> 
>>>> <mailto:Richard.Hillegas@Sun.COM> writes:
>>>>>  conn.rollback();
>>>> Doesn't the rollback block on synchronizion on the connection?
>>>> Dag

View raw message