Re: waitpid in pg_basebackup

Lists: pgsql-hackers
From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: waitpid in pg_basebackup
Date: 2012-07-04 16:58:49
Message-ID: CAHGQGwEjnf7wPe5b=hJoAWrXCDrd-DhAXf1jdwQ6kLy4e_YNig@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi,

waitpid() is used with "#ifdef HAVE_WAITPID" in reaper(), but NOT in
BaseBackup().
Why not? We can ensure that all platforms which PostgreSQL supports
have waitpid()?
If so, can we get rid of "#ifdef HAVE_WAITPID" in reaper()?

Regards,

--
Fujii Masao


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: waitpid in pg_basebackup
Date: 2012-07-04 17:54:47
Message-ID: 25402.1341424487@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Fujii Masao <masao(dot)fujii(at)gmail(dot)com> writes:
> waitpid() is used with "#ifdef HAVE_WAITPID" in reaper(), but NOT in
> BaseBackup().
> Why not? We can ensure that all platforms which PostgreSQL supports
> have waitpid()?
> If so, can we get rid of "#ifdef HAVE_WAITPID" in reaper()?

The Single Unix Spec V2 (1997) specifies both waitpid() and wait3(),
but says the latter is "legacy" and new applications should use only
waitpid(); furthermore it documents that platforms need not support
wait3() (they can just return ENOSYS instead of making it work).

I notice that pgbench also uses waitpid() unconditionally in its
"#ifndef ENABLE_THREAD_SAFETY" section. That's been there for
quite some time, making it even less likely that there are still
any platforms where waitpid() isn't available.

I agree, let's drop the support for waitpid() not being present.
It looks to me like we could remove the macro maze in reaper()
completely, if we fixed win32_waitpid() to not have an API randomly
different from the real waitpid(). That would be a noticeable
readability gain there.

regards, tom lane


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: waitpid in pg_basebackup
Date: 2012-07-05 17:01:25
Message-ID: 468.1341507685@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

I wrote:
> I agree, let's drop the support for waitpid() not being present.

BTW, some digging in the commit logs shows that postmaster.c's
existing support for using wait3 in place of waitpid was added in
commit a5494a2d92a2752c610b8b668a7d33478e90c160, "Various patches for
nextstep by GregorHoffleit". NextStep is presumably quite dead by
now, and anyway we officially pulled support for it as of 9.2.

I will go ahead and remove that code.

regards, tom lane


From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: waitpid in pg_basebackup
Date: 2012-07-05 17:43:33
Message-ID: CAHGQGwE=OMhxE3FFk10_exZ6Mw3TV0xXax6kJiO=JZyvDZ0v1g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, Jul 6, 2012 at 2:01 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> I wrote:
>> I agree, let's drop the support for waitpid() not being present.
>
> BTW, some digging in the commit logs shows that postmaster.c's
> existing support for using wait3 in place of waitpid was added in
> commit a5494a2d92a2752c610b8b668a7d33478e90c160, "Various patches for
> nextstep by GregorHoffleit". NextStep is presumably quite dead by
> now, and anyway we officially pulled support for it as of 9.2.
>
> I will go ahead and remove that code.

Thanks!

BTW, I was just implementing the patch ;) Patch attached.
Note that I've not tested the patch on Windows environment
because I don't have that....

Regards,

--
Fujii Masao

Attachment Content-Type Size
drop_ifdef_waitpid_v1.patch application/octet-stream 4.5 KB

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: waitpid in pg_basebackup
Date: 2012-07-05 18:12:23
Message-ID: 17550.1341511943@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Fujii Masao <masao(dot)fujii(at)gmail(dot)com> writes:
> On Fri, Jul 6, 2012 at 2:01 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> I will go ahead and remove that code.

> Thanks!

> BTW, I was just implementing the patch ;) Patch attached.

Oh, I'd already done it when I got your message :-(. Looks like we
arrived at the same answers, though, except for slightly different
choices for how to do the Windows bit.

> Note that I've not tested the patch on Windows environment
> because I don't have that....

Me either; I'll check the buildfarm results later.

regards, tom lane