Thread: query stuck at SOCK_wait_for_ready function call

query stuck at SOCK_wait_for_ready function call

From
"tamanna madaan"
Date:
Hi All
 
I am using postgres-8.1.2 and have been using psqlodbc-08.03.0200 driver to connect
to the databse. One of the queries I executed from my appilcation have got stuck for an
indefinite amount of time causing my application to hang. So I cored the application. The
core file gives a backtrace which shows it got stuck while waiting for a socket to get
ready as follows :
 
#0  0xb7fe4410 in ?? ()
#1  0xbfca07b8 in ?? ()
#2  0xffffffff in ?? ()
#3  0x00000001 in ?? ()
#4  0xb7d0fdc4 in poll () from /lib/tls/libc.so.6
#5  0xb6fef7b4 in SOCK_wait_for_ready (sock=0x87171d0, output=0, retry_count=1) at socket.c:529
#6  0xb6fefe9a in SOCK_get_next_byte (self=0x87171d0, peek=0) at socket.c:929
#7  0xb6ff005c in SOCK_get_id (self=0x87171d0) at socket.c:692
---Type <return> to continue, or q <return> to quit---
#8  0xb6fc851b in CC_send_query_append (self=0x8717d30, query=0x87222c0 "SELECT RUMaster(2) AS call_proc_result", qi=0x0,
    flag=0, stmt=0x8720730, appendq=0x0) at connection.c:2524
#9  0xb6ff9bb4 in SC_execute (self=0x8720730) at statement.c:1838
#10 0xb6fda7b6 in Exec_with_parameters_resolved (stmt=0x8720730, exec_end=0xbfca2be8) at execute.c:386
#11 0xb6fdbe62 in PGAPI_Execute (hstmt=0x8720730, flag=1) at execute.c:1062
#12 0xb70038ea in SQLExecute (StatementHandle=0x8720730) at odbcapi.c:374
#13 0xb7e8713c in SQLExecute (statement_handle=0x8720158) at SQLExecute.c:283

Can anyone please let me know what can cause this.
Even if it didnt find the socket ready ,  why not it simply come out giving some error
instead of getting stuck for an indefinite period.
 
Thanks...
Tamanna

Re: query stuck at SOCK_wait_for_ready function call

From
Raymond O'Donnell
Date:
On 30/12/2010 10:28, tamanna madaan wrote:
> Hi All
>
> I am using postgres-8.1.2 and have been using psqlodbc-08.03.0200 driver to connect

I'd imagine you're going to get a *flood* of responses saying this, but
here goes anyway - the version of Postgres you're using is VERY old, and
missing 21 sets of bug fixes; the 8.1 branch is up to 8.1.23. In fact,
to my knowledge the entire 8.1 branch is end-of-life; certainly on
Windows anyway.

I can't shed any light on your problem, but you should certainly upgrade
if you can, as there's a fair chance that your problem might arise from
a bug fixed in a later version.

Ray.


--
Raymond O'Donnell :: Galway :: Ireland
rod@iol.ie

Re: query stuck at SOCK_wait_for_ready function call

From
Tom Lane
Date:
"tamanna madaan" <tamanna.madan@globallogic.com> writes:
> I am using postgres-8.1.2 and have been using psqlodbc-08.03.0200 driver to connect
> to the databse. One of the queries I executed from my appilcation have got stuck for an
> indefinite amount of time causing my application to hang.

Are you sure you didn't simply issue a very long-running query?  Or one
that is waiting for a lock?

            regards, tom lane

Re: query stuck at SOCK_wait_for_ready function call

From
"tamanna madaan"
Date:

Thanks Tom for your reply .

However, This is not a very long running query.
This was supposed to update only one row in a table.
Moreover, it cant be waiting for a lock as
other processes were able to update the same table at the same time.
restarting the process which was stuck because of this query, also
resolved the issue. That means after restart, the process was able to
update the same table. Had it been waiting for a lock before , it wouldn't
have been able to update the table after restart either.


Regards
Tamanna


-----Original Message-----
From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
Sent: Thu 12/30/2010 11:23 PM
To: tamanna madaan
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] query stuck at SOCK_wait_for_ready function call

"tamanna madaan" <tamanna.madan@globallogic.com> writes:
> I am using postgres-8.1.2 and have been using psqlodbc-08.03.0200 driver to connect
> to the databse. One of the queries I executed from my appilcation have got stuck for an
> indefinite amount of time causing my application to hang.

Are you sure you didn't simply issue a very long-running query?  Or one
that is waiting for a lock?

                        regards, tom lane

Re: query stuck at SOCK_wait_for_ready function call

From
Alban Hertroys
Date:
On 31 Dec 2010, at 5:14, tamanna madaan wrote:

> Moreover, it cant be waiting for a lock as
> other processes were able to update the same table at the same time.

That only means it wasn't waiting on a TABLE-lock, occurrences of which are quite rare in Postgres. But if, for
example,an other update was updating the same row or if it was selected for update, then there would be a lock on that
row.

> restarting the process which was stuck because of this query, also
> resolved the issue. That means after restart, the process was able to
> update the same table.

After it restarted, was it updating the same row? If not, there's your explanation.

> Had it been waiting for a lock before , it wouldn't
> have been able to update the table after restart either.

It would have been able to, unless the table was being altered (ALTER TABLE foo ADD bar text) or some-such.

Did you upgrade to the latest minor release yet? Upgrading should be one of your first priorities for solving this
issue.

If you did and the problem still occurs; What is the query you were executing? From your backtrace it looks like you
wereexecuting  "SELECT RUMaster(2) AS call_proc_result". If so, what does that function do? 

You appear to be running Postgres on a Windows machine? Are you sure you don't have some anti-virus package getting in
theway locking files that are Postgres's? 

Alban Hertroys

--
If you can't see the forest for the trees,
cut the trees and you'll see there is no forest.


!DSPAM:737,4d1da96f802651773617067!



Re: query stuck at SOCK_wait_for_ready function call

From
Andrew Sullivan
Date:
On Fri, Dec 31, 2010 at 09:44:43AM +0530, tamanna madaan wrote:

> However, This is not a very long running query.
> This was supposed to update only one row in a table.

That it's supposed to update only one row does not mean it wasn't a
very long running query.

> Moreover, it cant be waiting for a lock as
> other processes were able to update the same table at the same time.

I don't see how that follows.  Postgres doesn't normally lock the
whole table.

> restarting the process which was stuck because of this query, also
> resolved the issue. That means after restart, the process was able to
> update the same table. Had it been waiting for a lock before , it wouldn't
> have been able to update the table after restart either.

I don't think that's true.  If you restarted, you killed all the
outstanding operations.  If something previously had a lock that was
blocking your query, that lock was removed.  Now your query can go
through.

In order to know whether there is a problem with a lock, you can use
the pg_locks system view.  Documentation is in the manual:
http://www.postgresql.org/docs/9.0/interactive/view-pg-locks.html (or,
for your release,
http://www.postgresql.org/docs/8.1/interactive/view-pg-locks.html).

By the way, the advice you got yesterday about upgrading is good
advice.  I wouldn't keep running the version you're running.

A

--
Andrew Sullivan
ajs@crankycanuck.ca

Re: query stuck at SOCK_wait_for_ready function call

From
"tamanna madaan"
Date:

Hi All

Now, I am using postgres-8.4.0 and psqlodbc-08.03.0400-1 and unixODBC-2.2.14-000.01 driver to connect
to the databse. Again having the same issue . One of the queries I executed from my application have got stuck for an
indefinite amount of time causing my application to hang. So I cored the application. The
core file gives a backtrace which shows it got stuck while waiting for a socket to get
ready as follows :

(gdb) bt
#0  0x00007f1c3e5ed366 in poll () from /lib64/libc.so.6
#1  0x00007f1c3a82d0a5 in SOCK_wait_for_ready (sock=0x7f1be67ff720, output=0, retry_count=1) at socket.c:531
#2  0x00007f1c3a82d8c3 in SOCK_get_next_byte (self=0x7f1be67ff720, peek=0) at socket.c:940
#3  0x00007f1c3a82db92 in SOCK_get_id (self=0x7f1be67ff720) at socket.c:696
#4  0x00007f1c3a8090ca in CC_send_query_append (self=0x7f1be68bf430, query=<value optimized out>, qi=0x0, flag=<value optimized out>, stmt=0x0,
    appendq=<value optimized out>) at connection.c:2498
#5  0x00007f1c3a818ae5 in PGAPI_Transact (henv=0x0, hdbc=0x7f1be68bf430, fType=0) at execute.c:1143
#6  0x00007f1c3a8424ec in SQLEndTran (HandleType=<value optimized out>, Handle=0x7f1be68bf430, CompletionType=-1) at odbcapi30.c:178
#7  0x00007f1c3f62fa2b in SQLEndTran (handle_type=<value optimized out>, handle=0x7f1beff16b90, completion_type=0) at SQLEndTran.c:360


One other thread of the same process was also stuck :

(gdb) bt
#0  0x00007f1c3e5ed366 in poll () from /lib64/libc.so.6
#1  0x00007f1c3a82d0a5 in SOCK_wait_for_ready (sock=0x2bcde60, output=0, retry_count=1) at socket.c:531
#2  0x00007f1c3a82d8c3 in SOCK_get_next_byte (self=0x2bcde60, peek=0) at socket.c:940
#3  0x00007f1c3a82db92 in SOCK_get_id (self=0x2bcde60) at socket.c:696
#4  0x00007f1c3a8090ca in CC_send_query_append (self=0x2bd13a0, query=<value optimized out>, qi=0x0, flag=<value optimized out>, stmt=0x7f1bf766c380,
    appendq=<value optimized out>) at connection.c:2498
#5  0x00007f1c3a836c94 in SC_execute (self=0x7f1bf766c380) at statement.c:1879
#6  0x00007f1c3a81907e in Exec_with_parameters_resolved (stmt=0x7f1bf766c380, exec_end=0x7f1c2c59e4c0) at execute.c:386
#7  0x00007f1c3a81a600 in PGAPI_Execute (hstmt=0x7f1bf766c380, flag=<value optimized out>) at execute.c:1070
#8  0x00007f1c3a83fd82 in SQLExecute (StatementHandle=0x7f1bf766c380) at odbcapi.c:374
#9  0x00007f1c3f630c77 in SQLExecute (statement_handle=0x7f1be4b069e0) at SQLExecute.c:283


I had the same issue while using postgres-8.1.2 and was advised to upgrade postgres.


But upgrading the postgres version didn't resolve the issue  .
There doesn't seem to be any locking issue . 

Can anyone please shed some light on this issue .


Thanks...
Tamanna



From: Alban Hertroys [mailto:dalroi@solfertje.student.utwente.nl]
Sent: Fri 12/31/2010 3:28 PM
To: tamanna madaan
Cc: Tom Lane; pgsql-general@postgresql.org
Subject: Re: [GENERAL] query stuck at SOCK_wait_for_ready function call

On 31 Dec 2010, at 5:14, tamanna madaan wrote:

> Moreover, it cant be waiting for a lock as
> other processes were able to update the same table at the same time.

That only means it wasn't waiting on a TABLE-lock, occurrences of which are quite rare in Postgres. But if, for example, an other update was updating the same row or if it was selected for update, then there would be a lock on that row.

> restarting the process which was stuck because of this query, also
> resolved the issue. That means after restart, the process was able to
> update the same table.

After it restarted, was it updating the same row? If not, there's your explanation.

> Had it been waiting for a lock before , it wouldn't
> have been able to update the table after restart either.

It would have been able to, unless the table was being altered (ALTER TABLE foo ADD bar text) or some-such.

Did you upgrade to the latest minor release yet? Upgrading should be one of your first priorities for solving this issue.

If you did and the problem still occurs; What is the query you were executing? From your backtrace it looks like you were executing  "SELECT RUMaster(2) AS call_proc_result". If so, what does that function do?

You appear to be running Postgres on a Windows machine? Are you sure you don't have some anti-virus package getting in the way locking files that are Postgres's?

Alban Hertroys

--
If you can't see the forest for the trees,
cut the trees and you'll see there is no forest.


!DSPAM:1210,4d1da969802651767083970!