Re: [w32] test_shm_mq test suite permanently burns connections slots

Lists: pgsql-hackers
From: Noah Misch <noah(at)leadboat(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>
Subject: [w32] test_shm_mq test suite permanently burns connections slots
Date: 2014-07-25 19:25:13
Message-ID: 20140725192513.GA2380@gust
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On a Windows or other EXEC_BACKEND build, the following eventually gets
failures because all, or all but one, max_connections slot is consumed:

for run in `seq 1 100`; do make -C contrib/test_shm_mq installcheck; done

When I use max_connections=40, it fails on the sixth iteration. Only the six
basic processes are actually running at that time.

Thanks,
nm

--
Noah Misch
EnterpriseDB http://www.enterprisedb.com


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Noah Misch <noah(at)leadboat(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [w32] test_shm_mq test suite permanently burns connections slots
Date: 2014-07-28 19:59:37
Message-ID: CA+TgmoYuKiWB0eghiNjRqN9g-76epSouNPQZwUnPb5-xfyTnbw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, Jul 25, 2014 at 3:25 PM, Noah Misch <noah(at)leadboat(dot)com> wrote:
> On a Windows or other EXEC_BACKEND build, the following eventually gets
> failures because all, or all but one, max_connections slot is consumed:
>
> for run in `seq 1 100`; do make -C contrib/test_shm_mq installcheck; done
>
> When I use max_connections=40, it fails on the sixth iteration. Only the six
> basic processes are actually running at that time.

The tests start 7 workers each time, so that makes sense: 7 * 5 < 40
but 7 * 6 > 40. What I'm not sure is why they are leaking connection
slots, and why they're only doing it in EXEC_BACKEND mode. A quick
code audit didn't uncover any obvious explanation, so I'll try to
reproduce and debug.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Noah Misch <noah(at)leadboat(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [w32] test_shm_mq test suite permanently burns connections slots
Date: 2014-07-28 20:36:52
Message-ID: CA+TgmoZbyAji_Oj46G8YnkZh__FzRjNZxfvAmvs_8foaizckxw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Jul 28, 2014 at 3:59 PM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> On Fri, Jul 25, 2014 at 3:25 PM, Noah Misch <noah(at)leadboat(dot)com> wrote:
>> On a Windows or other EXEC_BACKEND build, the following eventually gets
>> failures because all, or all but one, max_connections slot is consumed:
>>
>> for run in `seq 1 100`; do make -C contrib/test_shm_mq installcheck; done
>>
>> When I use max_connections=40, it fails on the sixth iteration. Only the six
>> basic processes are actually running at that time.
>
> The tests start 7 workers each time, so that makes sense: 7 * 5 < 40
> but 7 * 6 > 40. What I'm not sure is why they are leaking connection
> slots, and why they're only doing it in EXEC_BACKEND mode. A quick
> code audit didn't uncover any obvious explanation, so I'll try to
> reproduce and debug.

OK, I think I see the problem. In EXEC_BACKEND mode,
SubPostmasterMain() calls InitProcess() before IsBackgroundWorker has
been set. InitProcess() therefore pulls the PGPROC for the worker
from freeProcs rather than bgworkerFreeProcs. By exit time,
IsBackgroundWorker has been set, so the PGPROC gets put back on the
bgworkerFreeProcs list. Eventually there are no regular PGPROCs left;
they've all been moved to the bgworkerFreeProcs list.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Noah Misch <noah(at)leadboat(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [w32] test_shm_mq test suite permanently burns connections slots
Date: 2014-07-29 01:38:41
Message-ID: 20140729013841.GQ5475@eldon.alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Robert Haas wrote:

> OK, I think I see the problem. In EXEC_BACKEND mode,
> SubPostmasterMain() calls InitProcess() before IsBackgroundWorker has
> been set. InitProcess() therefore pulls the PGPROC for the worker
> from freeProcs rather than bgworkerFreeProcs. By exit time,
> IsBackgroundWorker has been set, so the PGPROC gets put back on the
> bgworkerFreeProcs list. Eventually there are no regular PGPROCs left;
> they've all been moved to the bgworkerFreeProcs list.

Doh. I'm surprised -- I tested a worker that crashed over and over to
ensure PGPROCs were reused sanely. I guess I forgot to run it under
EXEC_BACKEND.

Are you fixing it?

--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: Noah Misch <noah(at)leadboat(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [w32] test_shm_mq test suite permanently burns connections slots
Date: 2014-07-30 15:37:28
Message-ID: CA+Tgmob21iMFrQ4fwHAFDQm5dQ1nhMvC=uQOG7ATmENXbOuF3w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Jul 28, 2014 at 9:38 PM, Alvaro Herrera
<alvherre(at)2ndquadrant(dot)com> wrote:
> Robert Haas wrote:
>> OK, I think I see the problem. In EXEC_BACKEND mode,
>> SubPostmasterMain() calls InitProcess() before IsBackgroundWorker has
>> been set. InitProcess() therefore pulls the PGPROC for the worker
>> from freeProcs rather than bgworkerFreeProcs. By exit time,
>> IsBackgroundWorker has been set, so the PGPROC gets put back on the
>> bgworkerFreeProcs list. Eventually there are no regular PGPROCs left;
>> they've all been moved to the bgworkerFreeProcs list.
>
> Doh. I'm surprised -- I tested a worker that crashed over and over to
> ensure PGPROCs were reused sanely. I guess I forgot to run it under
> EXEC_BACKEND.
>
> Are you fixing it?

Working on it now.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company