You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by Daniel John Debrunner <dj...@debrunners.com> on 2005/06/02 18:08:42 UTC
Re: Implementing Statement.cancel()
Oyvind.Bakksjo@sun.com wrote:
> Daniel John Debrunner wrote:
>
>> Oyvind.Bakksjo@Sun.COM wrote:
>>
>>
>>> I've been looking at implementing Statement.cancel(), and later,
>>> Statement.setQueryTimeout().
>>
>>
>>
>> So, quick summary, that method is not suitable for finding the correct
>> StatementContext from EmbedStatement.cancel().
>>
>> I'll look into how I think you should track down the StatementContext.
>> Dan.
>
>
> Hi Dan,
>
> have you had any time to look into this?
Not a lot :-(
I've been thinking about it and there are a couple of issues:
1) StatementContexts are created dynamically for the current running
statement
2) Derby does not keep references to application JDBC objects below the
JDBC layer. This is to ensure when any JDBC object (e.g. Statement)
moves out of scope for the application, it will be garbage collected and
lead to its closure.
I wonder if from a StatementContext you can determine the activation
because that would provide the link to the Statement.
Dan.
Re: Implementing Statement.cancel()
Posted by Oy...@Sun.COM.
Daniel John Debrunner wrote:
> Oyvind.Bakksjo@sun.com wrote:
>
>
>>Daniel John Debrunner wrote:
>>
>>>I'll look into how I think you should track down the StatementContext.
>>>Dan.
>>
>>
>>Hi Dan,
>>
>>have you had any time to look into this?
>
> Not a lot :-(
So I assumed, so I started digging deeper into it myself. I wrongfully
assumed that a statement execution had a context object for its
lifetime. Once I found out that the StatementContext object is assigned
only when the statement is actively executing (setInUse/clearInUse is
called, for instance, for each fetch from the ResultSet), I realized
that there might not *be* an assigned StatementContext object when a
thread calls cancel(). Therefore, I'll have to come up with a different
solution for the cancel method.
On the other hand, I now have a working implementation of
setQueryTimeout (which is actually what the DERBY-31 JIRA issue is
requesting). cancel() is not a prerequisite for setQueryTimeout().
Statement execution propagates the timeout value down to the point where
a StatementContext object is assigned (with setInUse), and a TimerTask
(which, on timeout, sets a cancellation flag in the StatementContext
object) is scheduled on a system-wide Timer. Hence, there'll be one more
thread in the JVM per loaded Derby system (not per database). On
clearInUse(), the TimerTask is cancelled.
I'm in the process of polishing a patch and writing functional tests for
setQueryTimeout.
> I've been thinking about it and there are a couple of issues:
>
> 1) StatementContexts are created dynamically for the current running
> statement
>
> 2) Derby does not keep references to application JDBC objects below the
> JDBC layer. This is to ensure when any JDBC object (e.g. Statement)
> moves out of scope for the application, it will be garbage collected and
> lead to its closure.
>
> I wonder if from a StatementContext you can determine the activation
> because that would provide the link to the Statement.
Maybe that will be needed for implementing cancel(). I'll look into it
when I've finished the current patch for setQueryTimeout().
--
Øyvind Bakksjø
Sun Microsystems, Web Services, Database Technology Group
Haakon VII gt. 7b, N-7485 Trondheim, Norway
Tel: x43419 / +47 73842119, Fax: +47 73842101
Re: Implementing Statement.cancel()
Posted by David Van Couvering <Da...@Sun.COM>.
I have had similar difficulties finding navigation paths from one object
to another within the domain of execution contexts.
I have been toying with the idea of putting together one or two UML
class diagrams (using an open-source tool, of course :)) to try and show
the relationships between all these numerous classes and interfaces.
Every time I get in there I have to re-learn how the pieces fit
together, and often my internal buffer overflows and I get lost :)
It would also be great to document some of the design
principles/approaches to this layer of the code, as it's not at all
clear through reading the code. I don't have this knowledge, but if
someone who does can type something up, I can try and put it into a form
that can be posted as a paper to the web site.
David
Daniel John Debrunner wrote:
> Oyvind.Bakksjo@sun.com wrote:
>
>
>>Daniel John Debrunner wrote:
>>
>>
>>>Oyvind.Bakksjo@Sun.COM wrote:
>>>
>>>
>>>
>>>>I've been looking at implementing Statement.cancel(), and later,
>>>>Statement.setQueryTimeout().
>>>
>>>
>>>
>>>So, quick summary, that method is not suitable for finding the correct
>>>StatementContext from EmbedStatement.cancel().
>>>
>>>I'll look into how I think you should track down the StatementContext.
>>>Dan.
>>
>>
>>Hi Dan,
>>
>>have you had any time to look into this?
>
> Not a lot :-(
>
> I've been thinking about it and there are a couple of issues:
>
> 1) StatementContexts are created dynamically for the current running
> statement
>
> 2) Derby does not keep references to application JDBC objects below the
> JDBC layer. This is to ensure when any JDBC object (e.g. Statement)
> moves out of scope for the application, it will be garbage collected and
> lead to its closure.
>
> I wonder if from a StatementContext you can determine the activation
> because that would provide the link to the Statement.
>
>
> Dan.
>
>
>