pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>
To: tgl@sss.pgh.pa.us
Cc: pgsql-hackers@postgresql.org
Subject: Re: Parallel pg_dump's error reporting doesn't work worth squat
Date: Thu, 02 Jun 2016 17:49:41 +0900 (Tokyo Standard Time)
Message-ID: <20160602.174941.256342236.horiguchi.kyotaro@lab.ntt.co.jp> (raw)
In-Reply-To: <7445.1464712190@sss.pgh.pa.us>
References: <14603.1464369620@sss.pgh.pa.us>
	<20160531.180204.85313767.horiguchi.kyotaro@lab.ntt.co.jp>
	<7445.1464712190@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

Apart from the invalid snapshot problem, I looked the patch
previously mentioned mainly for Windows.

At Tue, 31 May 2016 12:29:50 -0400, Tom Lane <tgl@sss.pgh.pa.us> wrote in <7445.1464712190@sss.pgh.pa.us>
> In the patch I posted yesterday, I reversed the order of those two
> steps, which should fix this problem in most scenarios:
> https://www.postgresql.org/message-id/7005.1464657274@sss.pgh.pa.us

Entering ctrl-C while parallel pg_dump is running, on my console
I saw a repetition of the following error message, which is not
seen on Linux thanks to forcible termination of worker processes
in sigTermHandler().

> pg_dump: Dumping the contents of table "t" failed: PQgetResult() failed.
> pg_dump: Error message from server: ERROR:  canceling statement due to user request
> pg_dump: The command was: COPY public.t (a) TO stdout;

We could provide a global flag (wantAbort?) that inform the
canceling of queries but it needs adding checks for it
everywhere.

Even though the threads started by beginthread cannot be
terminated cleanly from outside, but the whole process will soon
terminate anyway, so we could use TreminateThread. This seems
working. (Attached patch) We might be allowed to do exit() in
colsoleHandler().


Other questions follow.

Is there any reason for the name "ourAH" not to be "myAH"?

setup_cancel_handler looks somewhat bizarre. It eventually works
only for the main process/thread and does nothing for workers. It
is enough to be run once before forking in ParalleBackupStart and
that makes handler_set unnecessary.

In EndDBCopyMode, the result of PQgetResult is abandoned. This
can leak memory and such usage is not seen elsewhere in the
source tree. Shouldn't we hold the result and PQclear it? (Mainly
as a convention, not for benefit.)

regards,

-- 
Kyotaro Horiguchi
NTT Open Source Software Center

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

Attachments:

dump-restore-sigint-1-silence-master-win32.patch (text/x-patch, 864B) download diff --git a/src/bin/pg_dump/parallel.c b/src/bin/pg_dump/parallel.c index cf97d9c..fb48a02 100644 --- a/src/bin/pg_dump/parallel.c +++ b/src/bin/pg_dump/parallel.c @@ -618,6 +618,12 @@ consoleHandler(DWORD dwCtrlType) { ArchiveHandle *AH = signal_info.pstate->parallelSlot[i].args->AH; + /* + * Using TerminateThread here may leave some resources leaked + * but whole this process will soon die. + */ + TerminateThread(signal_info.pstate->parallelSlot[i].hThread, 0); + if (AH != NULL && AH->connCancel != NULL) (void) PQcancel(AH->connCancel, errbuf, sizeof(errbuf)); } @@ -632,6 +638,8 @@ consoleHandler(DWORD dwCtrlType) errbuf, sizeof(errbuf)); LeaveCriticalSection(&signal_info_lock); + + write_msg(NULL, "terminated by user\n"); } /* Always return FALSE to allow signal handling to continue */

view thread (33+ messages)  latest in thread

Message-ID: <20160602.174941.256342236.horiguchi.kyotaro@lab.ntt.co.jp>
Permalink:  ../20160602.174941.256342236.horiguchi.kyotaro@lab.ntt.co.jp/
Also on:    postgresql.org/message-id/20160602.174941.256342236.horiguchi.kyotaro@lab.ntt.co.jp

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: horiguchi.kyotaro@lab.ntt.co.jp, tgl@sss.pgh.pa.us
  Subject: Re: Parallel pg_dump's error reporting doesn't work worth squat
  In-Reply-To: <20160602.174941.256342236.horiguchi.kyotaro@lab.ntt.co.jp>
  References: <14603.1464369620@sss.pgh.pa.us> <20160531.180204.85313767.horiguchi.kyotaro@lab.ntt.co.jp> <7445.1464712190@sss.pgh.pa.us> <20160602.174941.256342236.horiguchi.kyotaro@lab.ntt.co.jp>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox