Unix Technical Forum

SQL query never ends

This is a discussion on SQL query never ends within the pgsql Interfaces jdbc forums, part of the PostgreSQL category; --> I'm experimenting a random problem on my PC. Sometimes a sql query executed with Statement never returns. The code ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Interfaces jdbc

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-16-2008, 12:13 AM
James Im
 
Posts: n/a
Default SQL query never ends

I'm experimenting a random problem on my PC. Sometimes a sql query
executed with Statement never returns. The code is blocked at a line
like this one:

rs = stmt.executeQuery("select true");

The query is not important: it fails with any type of query, at random,
even with the one above.

I never get an exception.

Now the logs. I've enable logging at the database level and I have set
"statement_timeout = 3000". I have searched for the query in
postgresql's log but I cannot find the query which is blocking in my
java code so I guess that it means that the query never reached postgresql.

I've enabled jdbc logging with "loglevel=2" and this is what I get:

simple execute,
handler=org.postgresql.jdbc2.AbstractJdbc2Statemen t$StatementResultHandler@996cca,
maxRows=0, fetchSize=0, flags=17
FE=> Parse(stmt=null,query="i've remove the select query",oids={})
FE=> Bind(stmt=null,portal=null)
FE=> Describe(portal=null)
FE=> Execute(portal=null,limit=0)
FE=> Sync

... and nothing else. No "<=BE ..." follow the " FE=> Sync" log entry.


I've also tried to put "stmt.setQueryTimeout(3);" but it doesn't seem to
do anything.

I'm using postgresql 8.1.4 on Windows 2000 Pro SP4 and the driver is
"8.1-407 JDBC 3". I'm also using java 1.5.0_06-b05.


I guess that there is a bug in the driver. If I'm wrong, please tell me
how to solve it. If I'm right, could you try to fix it?

__________________________________________________ _______________
Log på MSN Messenger direkte på nettet: http://webmessenger.msn.com


---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-16-2008, 12:13 AM
Mark Lewis
 
Posts: n/a
Default Re: SQL query never ends

This sort of behavior often indicates some kind of unsafe concurrent
usage of the JDBC Connection. Is this running in a multi-threaded
environment? If so, are there measures in place to ensure that only one
thread uses the connection at a time?

It would also be useful if you could do a thread dump while it's hanging
and send a stack trace of the affected thread.

-- Mark

On Wed, 2006-08-09 at 10:21 +0000, James Im wrote:
> I'm experimenting a random problem on my PC. Sometimes a sql query
> executed with Statement never returns. The code is blocked at a line
> like this one:
>
> rs = stmt.executeQuery("select true");
>
> The query is not important: it fails with any type of query, at random,
> even with the one above.
>
> I never get an exception.
>
> Now the logs. I've enable logging at the database level and I have set
> "statement_timeout = 3000". I have searched for the query in
> postgresql's log but I cannot find the query which is blocking in my
> java code so I guess that it means that the query never reached postgresql.
>
> I've enabled jdbc logging with "loglevel=2" and this is what I get:
>
> simple execute,
> handler=org.postgresql.jdbc2.AbstractJdbc2Statemen t$StatementResultHandler@996cca,
> maxRows=0, fetchSize=0, flags=17
> FE=> Parse(stmt=null,query="i've remove the select query",oids={})
> FE=> Bind(stmt=null,portal=null)
> FE=> Describe(portal=null)
> FE=> Execute(portal=null,limit=0)
> FE=> Sync
>
> .. and nothing else. No "<=BE ..." follow the " FE=> Sync" log entry.
>
>
> I've also tried to put "stmt.setQueryTimeout(3);" but it doesn't seem to
> do anything.
>
> I'm using postgresql 8.1.4 on Windows 2000 Pro SP4 and the driver is
> "8.1-407 JDBC 3". I'm also using java 1.5.0_06-b05.
>
>
> I guess that there is a bug in the driver. If I'm wrong, please tell me
> how to solve it. If I'm right, could you try to fix it?
>
> __________________________________________________ _______________
> Log p MSN Messenger direkte p nettet: http://webmessenger.msn.com
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly


---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-16-2008, 12:13 AM
Dave Cramer
 
Posts: n/a
Default Re: SQL query never ends

James,

We will need more information in order to help you here.

As Mark said, are you using this concurrently ?

Dave
On 9-Aug-06, at 6:21 AM, James Im wrote:

> I'm experimenting a random problem on my PC. Sometimes a sql query
> executed with Statement never returns. The code is blocked at a line
> like this one:
>
> rs = stmt.executeQuery("select true");
>
> The query is not important: it fails with any type of query, at
> random,
> even with the one above.
>
> I never get an exception.
>
> Now the logs. I've enable logging at the database level and I have set
> "statement_timeout = 3000". I have searched for the query in
> postgresql's log but I cannot find the query which is blocking in my
> java code so I guess that it means that the query never reached
> postgresql.
>
> I've enabled jdbc logging with "loglevel=2" and this is what I get:
>
> simple execute,
> handler=org.postgresql.jdbc2.AbstractJdbc2Statemen t
> $StatementResultHandler@996cca,
> maxRows=0, fetchSize=0, flags=17
> FE=> Parse(stmt=null,query="i've remove the select query",oids={})
> FE=> Bind(stmt=null,portal=null)
> FE=> Describe(portal=null)
> FE=> Execute(portal=null,limit=0)
> FE=> Sync
>
> .. and nothing else. No "<=BE ..." follow the " FE=> Sync" log entry.
>
>
> I've also tried to put "stmt.setQueryTimeout(3);" but it doesn't
> seem to
> do anything.
>
> I'm using postgresql 8.1.4 on Windows 2000 Pro SP4 and the driver is
> "8.1-407 JDBC 3". I'm also using java 1.5.0_06-b05.
>
>
> I guess that there is a bug in the driver. If I'm wrong, please
> tell me
> how to solve it. If I'm right, could you try to fix it?
>
> __________________________________________________ _______________
> Log på MSN Messenger direkte på nettet: http://webmessenger.msn.com
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that
> your
> message can get through to the mailing list cleanly
>



---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-16-2008, 12:13 AM
Oliver Jowett
 
Posts: n/a
Default Re: SQL query never ends

James Im wrote:
> I'm experimenting a random problem on my PC. Sometimes a sql query
> executed with Statement never returns.


> simple execute,
> handler=org.postgresql.jdbc2.AbstractJdbc2Statemen t$StatementResultHandler@996cca,
>
> maxRows=0, fetchSize=0, flags=17
> FE=> Parse(stmt=null,query="i've remove the select query",oids={})
> FE=> Bind(stmt=null,portal=null)
> FE=> Describe(portal=null)
> FE=> Execute(portal=null,limit=0)
> FE=> Sync
>
> .. and nothing else. No "<=BE ..." follow the " FE=> Sync" log entry.


This seems normal enough. What is logged immediately before before this?

Can you capture the network traffic between the server and JDBC driver?
If it's a concurrency issue we should see something at the connection
level. I'm not familiar with what windows tools are available to take
network captures (in the unix world I'd use tcpdump/snoop/ethereal), but
if you manage to get something in a format that ethereal will read, send
me the raw capture off-list and I'll take a look.

> I've also tried to put "stmt.setQueryTimeout(3);" but it doesn't seem to
> do anything.


setQueryTimeout() is a no-op in the current driver.

-O

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 08:28 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com