Logger process and "LOG: could not close client or listen socket: Bad file descriptor"

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Subject: Logger process and "LOG: could not close client or listen socket: Bad file descriptor"
Date: 2023-08-28 00:52:09
Message-ID: ZOvvuQe0rdj2slA9@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi all,
(Heikki in CC.)

After b0bea38705b2, I have noticed that the syslogger is generating a
lot of dummy LOG entries:
2023-08-28 09:40:52.565 JST [24554]
LOG: could not close client or listen socket: Bad file descriptor

The only reason why I have noticed this issue is because I enable the
logging collector in my development scripts. Note that the pg_ctl
test 004_logrotate.pl, the only one with logging_collector set, is
equally able to reproduce the issue.

The root of the problem is ClosePostmasterPorts() in syslogger.c,
where we close the postmaster ports, but all of them are still set at
0, leading to these spurious logs.

From what I can see, this is is a rather old issue, because
ListenSocket[] is filled with PGINVALID_SOCKET *after* starting the
syslogger. It seems to me that we should just initialize the array
before starting the syslogger, so as we don't get these incorrect
logs?

Thoughts? Please see the attached.
--
Michael

Attachment Content-Type Size
syslogger-sockets.patch text/x-diff 1.2 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2023-08-28 01:53:52 Re: pg_stat_get_backend_subxact() and backend IDs?
Previous Message Peter Smith 2023-08-28 00:04:45 Re: subscription/015_stream sometimes breaks