From: Radosław Smogura <rsmogura@softperience.eu>
To: pgsql-jdbc@postgresql.org
Subject: Implementation of query timeout
Date: Thu, 29 Oct 2009 15:19:58 +0100
Message-ID: <200910291519.58180.rsmogura@softperience.eu> (raw)
Hello,
I send this message again, because there were problems with my email address,
so it didn't reach mailinglist.
I read a TODO list, and I decided to help a bit. So I've tried to implement
queryTimeout, currently ony for non-batch statements. You can see code, at
http://rsmogura.net/pgsql/pgsql_jdbc_querytimeout.tar.bz2
and analyze, chceck and test it.
Small description how it works.
1. When the query is executed it checks if timeout > 0.
2. If yes it creates TimerTask and add it to the queue, then sends the query
to server.
3. On timeout and if statement hasn't ended cancelStatement is called().
I've used Timer to don't create multiple threads with each statement. The
AbstractJdbc2 have setQueryTimeout method, so DataSources and
PolledConnections can utilze it to set Timer shared for all connections.
The QueryExecutor has new method executeSynchronized (description in API). To
prevent termination on next statement & run statements in current thread, the
lock on QueryExecutor is needed (so no other thread will send other query
until cancelStatement is fully called). This method can be more usefull then
synchronized(...) block and can be used later.
Some new utilities class has been added.
The test code creates non tempolary tables to simulate long-run by creating
data lock on two transactions.
If the JDBC will go to Java 5, some of this code can use new
java.util.concurent API.
Kind regards,
Radek Smogura
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: rsmogura@softperience.eu
Subject: Re: Implementation of query timeout
In-Reply-To: <200910291519.58180.rsmogura@softperience.eu>
References: <200910291519.58180.rsmogura@softperience.eu>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox