Re: Avoiding Statement.cancel() races

From: Kris Jurka <books(at)ejurka(dot)com>
To: Oliver Jowett <oliver(at)opencloud(dot)com>
Cc: <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Avoiding Statement.cancel() races
Date: 2003-11-21 11:18:07
Message-ID: Pine.LNX.4.33.0311210615030.32612-100000@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On Fri, 21 Nov 2003, Oliver Jowett wrote:

> However there's an obvious race condition here between starting query
> execution and cancelling the statement -- it's possible for
> stopWorkerThread() to run at just the wrong time and "cancel" the statement
> before it starts execution, having no effect and leaving the worker thread
> still running a query (at least as I understand cancel() .. that's how it's
> implemented in the postgresql driver anyway).

What if calling cancel on a non running statement threw an SQLException?
Then your stopWorkerThread could retry the cancel.

Kris Jurka

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Sverre H. Huseby 2003-11-21 20:58:59 Forcing use of cursor result sets
Previous Message Oliver Jowett 2003-11-21 02:14:16 Avoiding Statement.cancel() races