pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rob Emery <postgresql@mintsoft.net>
To: Michael Paquier <michael@paquier.xyz>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: [PATCH] Re: BUG #16032: pg_basebackup when running on Windows doesn't  clean up on failure correctly
Date: Mon, 07 Oct 2019 16:52:41 +0100
Message-ID: <8b5a4cd5812e2ec1e22ae1d9cc370ab2@mintsoft.net> (raw)
In-Reply-To: <20191007012132.GE14532@paquier.xyz>
References: <16032-4ba56823a2b2805f@postgresql.org>
	<0c6477f627e63c9cea68a6eda3f29a74@mintsoft.net>
	<20191007012132.GE14532@paquier.xyz>

Hiya Michael,

> Regarding your patch, anything living in the middle of processing
> (basically calling disconnect_and_exit() in ~11 and exit() for 12~)
> would fail into this category.  Wouldn't it make sense here to use
> atexit() to ensure that the cleanup always happens?  I am not sure
> that it is a good idea to hope that anything processing the base
> backup COPY chunks will remember to clean up those handles in the
> event of an error.  I am ready to bet that any future code will forget
> to add that so we would keep falling into the same trap.

Yes and no, the problem is that under Windows the file cleanup
occurs before the process itself actually ends, as the streaming of
the backup from the COPY is performed in a thread, not a fork.

So, if we attempt to use atexit to cleanup the filehandles,
pg_basebackup will still be attempting to delete the partial backup
before the file handles are cleaned up by the atexit callback.

I hope that makes sense; I agree with your sentiment that there must
be a better way of structuring this.

-Rob





view thread (4+ messages)

Message-ID: <8b5a4cd5812e2ec1e22ae1d9cc370ab2@mintsoft.net>
Permalink:  ../8b5a4cd5812e2ec1e22ae1d9cc370ab2@mintsoft.net/
Also on:    postgresql.org/message-id/8b5a4cd5812e2ec1e22ae1d9cc370ab2@mintsoft.net

 · 

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-bugs@postgresql.org
  Cc: postgresql@mintsoft.net, michael@paquier.xyz
  Subject: Re: [PATCH] Re: BUG #16032: pg_basebackup when running on Windows doesn't  clean up on failure correctly
  In-Reply-To: <8b5a4cd5812e2ec1e22ae1d9cc370ab2@mintsoft.net>
  References: <16032-4ba56823a2b2805f@postgresql.org> <0c6477f627e63c9cea68a6eda3f29a74@mintsoft.net> <20191007012132.GE14532@paquier.xyz> <8b5a4cd5812e2ec1e22ae1d9cc370ab2@mintsoft.net>

* 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