Re: [HACKERS] pg_archivecleanup bug (invalid filename input)

2015-06-10 Thread Michael Paquier
On Wed, Jun 10, 2015 at 12:29 PM, Joshua D. Drake j...@commandprompt.com wrote: On 06/09/2015 05:54 PM, Michael Paquier wrote: Looking at the documentation what is expected is not a path to a segment file, but only a segment file name:

Re: [HACKERS] pg_archivecleanup bug (invalid filename input)

2015-06-09 Thread Michael Paquier
On Wed, Jun 10, 2015 at 7:27 AM, Joshua D. Drake j...@commandprompt.com wrote: Trying to use pg_archivecleanup as a: standalone archive cleaner Results in an error of: pg_archivecleanup: invalid filename input Try pg_archivecleanup --help for more information.

Re: [HACKERS] pg_archivecleanup bug (invalid filename input)

2015-06-09 Thread Joshua D. Drake
On 06/09/2015 05:54 PM, Michael Paquier wrote: Looking at the documentation what is expected is not a path to a segment file, but only a segment file name: http://www.postgresql.org/docs/devel/static/pgarchivecleanup.html So the current behavior is correct, it is actually what

Re: [HACKERS] pg_archivecleanup bug

2014-03-21 Thread Bruce Momjian
On Wed, Mar 19, 2014 at 02:02:50PM -0400, Bruce Momjian wrote: The attached patch is slightly updated. I will apply it to head and all the back branches, including the stylistic change to pg_resetxlog (for consistency) and remove the MinGW block in head. Patch applied back through 8.4. I had

Re: [HACKERS] pg_archivecleanup bug

2014-03-19 Thread Heikki Linnakangas
On 03/19/2014 02:30 AM, Bruce Momjian wrote: On Tue, Mar 18, 2014 at 09:13:28PM +0200, Heikki Linnakangas wrote: On 03/18/2014 09:04 PM, Simon Riggs wrote: On 18 March 2014 18:55, Alvaro Herrera alvhe...@2ndquadrant.com wrote: That said, I don't find comma expression to be particularly not

Re: [HACKERS] pg_archivecleanup bug

2014-03-19 Thread Bruce Momjian
On Wed, Mar 19, 2014 at 09:59:19AM +0200, Heikki Linnakangas wrote: Would people accept? for (errno = 0; (dirent = readdir(dir)) != NULL; errno = 0) That would keep the errno's together and avoid the 'continue' additions. That's clever. A less clever way would be: for (;;) {

Re: [HACKERS] pg_archivecleanup bug

2014-03-18 Thread Bruce Momjian
On Tue, Mar 18, 2014 at 11:25:46AM +0530, Amit Kapila wrote: On Thu, Mar 13, 2014 at 11:18 AM, Bruce Momjian br...@momjian.us wrote: I have developed the attached patch which fixes all cases where readdir() wasn't checking for errno, and cleaned up the syntax in other cases to be

Re: [HACKERS] pg_archivecleanup bug

2014-03-18 Thread Tom Lane
Bruce Momjian br...@momjian.us writes: Very good point. I have modified the patch to add this block in all cases where it was missing. I started to wonder about the comment and if the Mingw fix was released. Based on some research, I see this as fixed in mingw-runtime-3.2, released

Re: [HACKERS] pg_archivecleanup bug

2014-03-18 Thread Robert Haas
On Tue, Mar 18, 2014 at 9:56 AM, Tom Lane t...@sss.pgh.pa.us wrote: Bruce Momjian br...@momjian.us writes: Very good point. I have modified the patch to add this block in all cases where it was missing. I started to wonder about the comment and if the Mingw fix was released. Based on some

Re: [HACKERS] pg_archivecleanup bug

2014-03-18 Thread Bruce Momjian
On Tue, Mar 18, 2014 at 10:03:46AM -0400, Robert Haas wrote: On Tue, Mar 18, 2014 at 9:56 AM, Tom Lane t...@sss.pgh.pa.us wrote: Bruce Momjian br...@momjian.us writes: Very good point. I have modified the patch to add this block in all cases where it was missing. I started to wonder about

Re: [HACKERS] pg_archivecleanup bug

2014-03-18 Thread Alvaro Herrera
Bruce Momjian escribió: On Tue, Mar 18, 2014 at 10:03:46AM -0400, Robert Haas wrote: On Tue, Mar 18, 2014 at 9:56 AM, Tom Lane t...@sss.pgh.pa.us wrote: Bruce Momjian br...@momjian.us writes: Very good point. I have modified the patch to add this block in all cases where it was

Re: [HACKERS] pg_archivecleanup bug

2014-03-18 Thread Simon Riggs
On 18 March 2014 14:15, Alvaro Herrera alvhe...@2ndquadrant.com wrote: Bruce Momjian escribió: On Tue, Mar 18, 2014 at 10:03:46AM -0400, Robert Haas wrote: On Tue, Mar 18, 2014 at 9:56 AM, Tom Lane t...@sss.pgh.pa.us wrote: Bruce Momjian br...@momjian.us writes: Very good point. I have

Re: [HACKERS] pg_archivecleanup bug

2014-03-18 Thread Robert Haas
On Tue, Mar 18, 2014 at 11:36 AM, Simon Riggs si...@2ndquadrant.com wrote: Given the above, this means we've run for about 7 years without a reported issue on this. If we are going to make this better by actually having it throw errors in places that didn't throw errors before, are we sure

Re: [HACKERS] pg_archivecleanup bug

2014-03-18 Thread Simon Riggs
On 18 March 2014 15:50, Robert Haas robertmh...@gmail.com wrote: On Tue, Mar 18, 2014 at 11:36 AM, Simon Riggs si...@2ndquadrant.com wrote: Given the above, this means we've run for about 7 years without a reported issue on this. If we are going to make this better by actually having it throw

Re: [HACKERS] pg_archivecleanup bug

2014-03-18 Thread Simon Riggs
On 13 March 2014 05:48, Bruce Momjian br...@momjian.us wrote: On Mon, Dec 9, 2013 at 11:27:28AM -0500, Robert Haas wrote: On Thu, Dec 5, 2013 at 6:15 PM, Tom Lane t...@sss.pgh.pa.us wrote: But the other usages seem to be in assorted utilities, which will need to do it right for themselves.

Re: [HACKERS] pg_archivecleanup bug

2014-03-18 Thread Bruce Momjian
On Tue, Mar 18, 2014 at 04:17:53PM +, Simon Riggs wrote: While I am not a fan of backpatching, the fact we are ignoring errors in some critical cases seems the non-cosmetic parts should be backpatched. pg_resetxlog was not an offender here; its coding was sound. We shouldn't be

Re: [HACKERS] pg_archivecleanup bug

2014-03-18 Thread Simon Riggs
On 18 March 2014 18:01, Bruce Momjian br...@momjian.us wrote: On Tue, Mar 18, 2014 at 04:17:53PM +, Simon Riggs wrote: While I am not a fan of backpatching, the fact we are ignoring errors in some critical cases seems the non-cosmetic parts should be backpatched. pg_resetxlog was not an

Re: [HACKERS] pg_archivecleanup bug

2014-03-18 Thread Bruce Momjian
On Tue, Mar 18, 2014 at 06:11:30PM +, Simon Riggs wrote: On 18 March 2014 18:01, Bruce Momjian br...@momjian.us wrote: On Tue, Mar 18, 2014 at 04:17:53PM +, Simon Riggs wrote: While I am not a fan of backpatching, the fact we are ignoring errors in some critical cases seems the

Re: [HACKERS] pg_archivecleanup bug

2014-03-18 Thread Alvaro Herrera
Bruce Momjian escribió: On Tue, Mar 18, 2014 at 06:11:30PM +, Simon Riggs wrote: On 18 March 2014 18:01, Bruce Momjian br...@momjian.us wrote: On Tue, Mar 18, 2014 at 04:17:53PM +, Simon Riggs wrote: While I am not a fan of backpatching, the fact we are ignoring errors in

Re: [HACKERS] pg_archivecleanup bug

2014-03-18 Thread Simon Riggs
On 18 March 2014 18:18, Bruce Momjian br...@momjian.us wrote: On Tue, Mar 18, 2014 at 06:11:30PM +, Simon Riggs wrote: On 18 March 2014 18:01, Bruce Momjian br...@momjian.us wrote: On Tue, Mar 18, 2014 at 04:17:53PM +, Simon Riggs wrote: While I am not a fan of backpatching, the

Re: [HACKERS] pg_archivecleanup bug

2014-03-18 Thread Alvaro Herrera
Simon Riggs escribió: On 18 March 2014 18:18, Bruce Momjian br...@momjian.us wrote: On Tue, Mar 18, 2014 at 06:11:30PM +, Simon Riggs wrote: Why make style changes at all? A patch with no style changes would mean backpatch and HEAD versions would be the same. The old style had

Re: [HACKERS] pg_archivecleanup bug

2014-03-18 Thread Simon Riggs
On 18 March 2014 18:55, Alvaro Herrera alvhe...@2ndquadrant.com wrote: That said, I don't find comma expression to be particularly not simple. Maybe, but we've not used it before anywhere in Postgres, so I don't see a reason to start now. Especially since C is not the native language of many

Re: [HACKERS] pg_archivecleanup bug

2014-03-18 Thread Heikki Linnakangas
On 03/18/2014 09:04 PM, Simon Riggs wrote: On 18 March 2014 18:55, Alvaro Herrera alvhe...@2ndquadrant.com wrote: That said, I don't find comma expression to be particularly not simple. Maybe, but we've not used it before anywhere in Postgres, so I don't see a reason to start now. Especially

Re: [HACKERS] pg_archivecleanup bug

2014-03-18 Thread Bruce Momjian
On Tue, Mar 18, 2014 at 09:13:28PM +0200, Heikki Linnakangas wrote: On 03/18/2014 09:04 PM, Simon Riggs wrote: On 18 March 2014 18:55, Alvaro Herrera alvhe...@2ndquadrant.com wrote: That said, I don't find comma expression to be particularly not simple. Maybe, but we've not used it before

Re: [HACKERS] pg_archivecleanup bug

2014-03-18 Thread Tom Lane
Bruce Momjian br...@momjian.us writes: Would people accept? for (errno = 0; (dirent = readdir(dir)) != NULL; errno = 0) It's a bit weird looking, but I agree that there's value in only needing the errno-zeroing in precisely one place. regards, tom lane -- Sent

Re: [HACKERS] pg_archivecleanup bug

2014-03-17 Thread Amit Kapila
On Thu, Mar 13, 2014 at 11:18 AM, Bruce Momjian br...@momjian.us wrote: I have developed the attached patch which fixes all cases where readdir() wasn't checking for errno, and cleaned up the syntax in other cases to be consistent. 1. One common thing missed wherever handling for errno is

Re: [HACKERS] pg_archivecleanup bug

2014-03-13 Thread Robert Haas
On Thu, Mar 13, 2014 at 1:48 AM, Bruce Momjian br...@momjian.us wrote: On Mon, Dec 9, 2013 at 11:27:28AM -0500, Robert Haas wrote: On Thu, Dec 5, 2013 at 6:15 PM, Tom Lane t...@sss.pgh.pa.us wrote: But the other usages seem to be in assorted utilities, which will need to do it right for

Re: [HACKERS] pg_archivecleanup bug

2014-03-12 Thread Bruce Momjian
On Mon, Dec 9, 2013 at 11:27:28AM -0500, Robert Haas wrote: On Thu, Dec 5, 2013 at 6:15 PM, Tom Lane t...@sss.pgh.pa.us wrote: But the other usages seem to be in assorted utilities, which will need to do it right for themselves. initdb.c's walkdir() seems to have it right and might be a

Re: [HACKERS] pg_archivecleanup bug

2013-12-10 Thread Bruce Momjian
On Thu, Dec 5, 2013 at 12:06:07PM -0800, Kevin Grittner wrote: An EDB customer reported a problem with pg_archivecleanup which I have looked into and found a likely cause.  It is, in any event, a bug which I think should be fixed.  It has to do with our use of the readdir() function:

Re: [HACKERS] pg_archivecleanup bug

2013-12-09 Thread Robert Haas
On Fri, Dec 6, 2013 at 11:10 AM, Tom Lane t...@sss.pgh.pa.us wrote: Robert Haas robertmh...@gmail.com writes: On Thu, Dec 5, 2013 at 6:15 PM, Tom Lane t...@sss.pgh.pa.us wrote: In general, I think there is no excuse for code in the backend to use readdir() directly; it should be using

Re: [HACKERS] pg_archivecleanup bug

2013-12-09 Thread Robert Haas
On Thu, Dec 5, 2013 at 6:15 PM, Tom Lane t...@sss.pgh.pa.us wrote: But the other usages seem to be in assorted utilities, which will need to do it right for themselves. initdb.c's walkdir() seems to have it right and might be a reasonable model to follow. Or maybe we should invent a

Re: [HACKERS] pg_archivecleanup bug

2013-12-06 Thread Robert Haas
On Thu, Dec 5, 2013 at 6:15 PM, Tom Lane t...@sss.pgh.pa.us wrote: In general, I think there is no excuse for code in the backend to use readdir() directly; it should be using ReadDir(), which takes care of this as well as error reporting. My understanding is that the fd.c infrastructure can't

Re: [HACKERS] pg_archivecleanup bug

2013-12-06 Thread Tom Lane
Robert Haas robertmh...@gmail.com writes: On Thu, Dec 5, 2013 at 6:15 PM, Tom Lane t...@sss.pgh.pa.us wrote: In general, I think there is no excuse for code in the backend to use readdir() directly; it should be using ReadDir(), which takes care of this as well as error reporting. My

Re: [HACKERS] pg_archivecleanup bug

2013-12-05 Thread Robert Haas
On Thu, Dec 5, 2013 at 3:06 PM, Kevin Grittner kgri...@ymail.com wrote: An EDB customer reported a problem with pg_archivecleanup which I have looked into and found a likely cause. It is, in any event, a bug which I think should be fixed. It has to do with our use of the readdir() function:

Re: [HACKERS] pg_archivecleanup bug

2013-12-05 Thread Tom Lane
Kevin Grittner kgri...@ymail.com writes: | Applications wishing to check for error situations should set | errno to 0 before calling readdir(). If errno is set to non-zero | on return, an error occurred. So an error in scanning the directory will not be reported; the cleanup will quietly