Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Is there a way to abort a long COPY?

1 view
Skip to first unread message

Anders Andersson

unread,
Jul 9, 2014, 8:45:19 PM7/9/14
to dbd...@perl.org
Hi! I'm reading a lot of data from a database using the "COPY
(SELECT...) TO STDOUT" method but occasionally I need to abort the
process mid-way. When doing that, it seems that the COPY process
continues on the server, long after I have disconnected from the
database in my script. Is there a way to tell the server to abort the
COPY?

$sth->finish() does not seem to do anything about it.

I'm using DBD::Pg 2.19.2 in my script and PostgreSQL 9.1 on the server
if that makes a difference.

// Anders

Greg Sabino Mullane

unread,
Jul 13, 2014, 10:04:37 PM7/13/14
to Anders Andersson, dbd...@perl.org
> database in my script. Is there a way to tell the server to abort the
> COPY?

Try bumping the logging level and see if your script is issuing a PQcancel
or not. It may or may not be, depending on how rudely things got interrupted.

Also keep in mind that long-running COPYs can take a while to "unwind". If
you are just looking for a way to cancel a still-running COPY, check the output
of pg_stat_activity and confirm it is running (and grab the PID), and then
send it a pg_cancel_backend(PID).

--
Greg Sabino Mullane gr...@endpoint.com
End Point Corporation
PGP Key: 0x14964AC8
signature.asc
0 new messages