Search Postgresql Archives

query cannot be terminated when client is suspended

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello, 
I tried the following scenario on PostgreSQL 9.4.2 on Linux:
1) Connect to a remote postgres database and run a long running query
   e.g. psql -h vm5 -p 57001 warehouse -c 'select x.a from
generate_series(1, 100000000) as x(a);'
2) Suspend the client process by pressing CTRL-Z
3) In another session, get the backend PID from pg_stat_activity and run
   pg_terminate_backend(PID)
     or
   pg_cancel_backend(PID)

The query hangs indeterminately and cannot be terminated.

Using strace, I see that the backend is stuck trying to send to the client
in the function internal_flush(), in send(). The backend does receive the
SIGINT or SIGTERM signal, but it is just restarting the system call.

sendto(9, "D\0\0\0\22\0\1\0\0\0\01017182365D\0\0\0\22\0\1\0\0\0\01017"...,
5392, 0, NULL, 0) = ? ERESTARTSYS (To be restarted)
--- SIGINT (Interrupt) @ 0 (0) ---
rt_sigreturn(0x2b85fc4234fc)            = 44
sendto(9, "D\0\0\0\22\0\1\0\0\0\01017182365D\0\0\0\22\0\1\0\0\0\01017"...,
5392, 0, NULL, 0) = ? ERESTARTSYS (To be restarted)
--- SIGTERM (Terminated) @ 0 (0) ---
rt_sigreturn(0x2b85fc4234fc)            = 44
sendto(9, "D\0\0\0\22\0\1\0\0\0\01017182365D\0\0\0\22\0\1\0\0\0\01017"...,
5392, 0, NULL, 0) = ? ERESTARTSYS (To be restarted)



We have several customers that see these "hanging" queries and have no way
of canceling them, and I suspect that this is the cause.

Has anyone else encountered this? Is there a way to cancel these queries,
or fix the problem in the code?

Thanks, 
George



-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux