Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id F318CB5DBC1 for ; Sat, 2 Jul 2011 06:29:46 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 31005-05 for ; Sat, 2 Jul 2011 09:29:40 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from www.postnewspapers.com.au (www.postnewspapers.com.au [173.230.139.50]) by mail.postgresql.org (Postfix) with ESMTP id B1C63B5D80A for ; Sat, 2 Jul 2011 06:29:40 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by www.postnewspapers.com.au (Postfix) with ESMTP id A7DA33E; Sat, 2 Jul 2011 05:29:39 -0400 (EDT) X-Virus-Scanned: amavisd-new at postnewspapers.com.au.com Received: from www.postnewspapers.com.au ([127.0.0.1]) by localhost (www.postnewspapers.com.au [127.0.0.1]) (amavisd-new, port 10024) with LMTP id ILKI+GgKBNvh; Sat, 2 Jul 2011 05:29:38 -0400 (EDT) Received: from mail.postnewspapers.com.au (ppp171-128.static.internode.on.net [150.101.171.128]) by www.postnewspapers.com.au (Postfix) with ESMTP id 9954327; Sat, 2 Jul 2011 05:29:38 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.postnewspapers.com.au (Postfix) with ESMTP id 4FDEAAEE3B; Sat, 2 Jul 2011 17:29:37 +0800 (WST) X-Virus-Scanned: Debian amavisd-new at postnewspapers.com.au Received: from mail.postnewspapers.com.au ([127.0.0.1]) by localhost (mail.postnewspapers.com.au [127.0.0.1]) (amavisd-new, port 10024) with LMTP id e+9K+fbp3MDy; Sat, 2 Jul 2011 17:29:32 +0800 (WST) Received: from [10.1.1.7] (124-169-57-156.dyn.iinet.net.au [124.169.57.156]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "Craig Ringer", Issuer "POST Certificate Authority" (verified OK)) by mail.postnewspapers.com.au (Postfix) with ESMTPSA id 4E0B6AEE2D; Sat, 2 Jul 2011 17:29:32 +0800 (WST) Message-ID: <4E0EE4FA.2020307@postnewspapers.com.au> Date: Sat, 02 Jul 2011 17:29:30 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20110624 Thunderbird/5.0 MIME-Version: 1.0 To: Maksym Boguk CC: pgsql-bugs@postgresql.org Subject: Re: BUG #6088: copy to stdout cannot be stopped with kill(pid) or pg_terminate_backend References: <201107020442.p624gahY078103@wwwmaster.postgresql.org> In-Reply-To: <201107020442.p624gahY078103@wwwmaster.postgresql.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201107/8 X-Sequence-Number: 30620 On 2/07/2011 12:42 PM, Maksym Boguk wrote: > But I found I can not stop > COPY bill.changes (id, cdate, mdate, status, table_name, pk_id, old_row, > new_row) TO stdout; > with pg_terminate_backend(procpid) or kill (procpid). Which FreeBSD are you on? Version and architecture. Can you obtain a backtrace of the backend you've sent the kill signal to, after you've set the signal? Given the rest of what you've said, I'll bet it's blocked in the kernel waiting to send data down a socket. If the kernel's socket writes aren't interrupted by signals, there's nothing much Pg can do about it. > At the same time copy to stdout completely ignore fact other side (pg_dump > itself) was killed long time ago. That's got to be a buffering issue, surely. Once the TCP send buffers fill up the backend would block in write() as the OS tries to send enough data to make room in the send buffer for the next write. If your OS keeps big buffers, Pg might've buffered many megabytes of data before you killed the client side. It might keep on trying to send that data for quite a long time if it doesn't get notified that the other peer (pg_dump in this case) has vanished. How were you running pg_dump? ssh was involved, so I'm wondering if you were running pg_dump over an ssh tcp tunnel. Was that it? Or were you running pg_dump on the server side and dumping the SQL text down the ssh connection to the client? If the latter, then unless you killed ssh as well the OS would merrily keep on sending the already-buffered data from before pg_dump was killed; you'd have to kill sshd or the client side of ssh to actually stop the data flow. To help with this sort of thing, reduce your send and receive buffer sizes. You'll pay a price in terms of throughput, but you'll gain responsiveness. Without more information, it's hard to know if this is anything except a buffering issue. Possibly one that doesn't even have anything to do with Pg - it could easily just be sshd writes being buffered. -- Craig Ringer