Re: Possible Bug: high CPU usage for stats collector in 8.2

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Darcy Buskermolen <darcyb(at)commandprompt(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Possible Bug: high CPU usage for stats collector in 8.2
Date: 2007-03-01 20:53:42
Message-ID: 45E73D56.5060809@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane wrote:
> Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
>
>> Good catch. I am also a bit dubious about this code:
>>
>
>
>> input_fd.fd = pgStatSock;
>> input_fd.events = POLLIN | POLLERR;
>> input_fd.revents = 0;
>>
>
> Hm. The Single Unix Spec saith that POLLERR is ignored in the events
> field, but it is not clear to me that older systems might not treat it
> as a condition bit. For instance on HPUX the poll man page says only
>
> The condition flags POLLERR, POLLHUP, and POLLNVAL are always set in
> revents if the conditions they indicate are true for the specified
> file descriptor, whether or not these flags are set in events.
>

yeah.

http://www.opengroup.org/onlinepubs/009695399/functions/poll.html says:

"An error has occurred on the device or stream. This flag is only valid
in the /revents/ bitmask; it shall be ignored in the /events/ member."

>
>> AIUI you are not supposed to put POLLERR in the events field. We should
>> probably be setting POLLIN | POLLPRI, and we should also probably check
>> exactly what event was returned in revents.
>>
>
> We don't need to check what was returned because the action is the same
> either way: do a recv(). I'm not seeing the point of setting POLLPRI.
>
>
>

Maybe none in this case - I guess we're not sending priority data.

This might all be OK - I just noticed it as I was looking at the
problem, so I though I'd mention it. I have no doubt your fix is the
correct one, though.

cheers

andrew

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jim C. Nasby 2007-03-01 20:58:55 Re: SOC & user quotas
Previous Message Tom Lane 2007-03-01 20:42:29 Re: Possible Bug: high CPU usage for stats collector in 8.2