Remove extra Logging_collector check before calling SysLogger_Start()

Started by Bharath Rupireddyalmost 5 years ago5 messageshackers
Beta feature

Hackorum builds and tests every patch posted to the lists, not only commitfest submissions. This is Hackorum's own CI rather than the PostgreSQL project's, and it is still under testing - please report anything that looks wrong.

won't retrysuccessCI history

You can run a PostgreSQL built from this patch straight from Docker, with no checkout and no build:

docker run --rm -p 5432:5432 ghcr.io/hackorum-dev/postgres-patch:t45195
psql -h localhost -U postgres

Built from patchset v1 (message #1), July 27, 2026 at 03:51 PM.

Every patchset is also pushed to a branch of our PostgreSQL fork, so you can check out the same tree CI built. Without a PostgreSQL checkout:

git clone --branch t45195_1 https://github.com/hackorum-dev/postgres.git

In a checkout you already have, add the fork once:

git remote add hackorum https://github.com/hackorum-dev/postgres.git

then, for this patchset and every later one:

git fetch hackorum t45195_1 && git checkout t45195_1

Patchset v1 (message #1) is on t45195_1

Jump to latest
#1Bharath Rupireddy
bharath.rupireddyforpostgres@gmail.com

Hi,

It seems like there's an extra Logging_collector check before calling
SysLogger_Start(). Note that the SysLogger_Start() has a check to
return 0 if Logging_collector is off. This change is consistent with
the other usage of SysLogger_Start().

                /* If we have lost the log collector, try to start a new one */
-               if (SysLoggerPID == 0 && Logging_collector)
+               if (SysLoggerPID == 0)
                        SysLoggerPID = SysLogger_Start();

Attaching a tiny patch to fix. Thoughts?

Regards,
Bharath Rupireddy.

Attachments:

t45195_1
v1-0001-remove-extra-Logging_collector-check-before-SysLo.patchapplication/octet-stream; name=v1-0001-remove-extra-Logging_collector-check-before-SysLo.patchDownload+1-2
#2Daniel Gustafsson
daniel@yesql.se
In reply to: Bharath Rupireddy (#1)
Re: Remove extra Logging_collector check before calling SysLogger_Start()

On 3 Dec 2021, at 08:58, Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com> wrote:

It seems like there's an extra Logging_collector check before calling
SysLogger_Start(). Note that the SysLogger_Start() has a check to
return 0 if Logging_collector is off. This change is consistent with
the other usage of SysLogger_Start().

/* If we have lost the log collector, try to start a new one */
-               if (SysLoggerPID == 0 && Logging_collector)
+               if (SysLoggerPID == 0)
SysLoggerPID = SysLogger_Start();

I think the code reads clearer with the Logging_collector check left intact,
and avoiding a function call in this codepath doesn't hurt.

--
Daniel Gustafsson https://vmware.com/

#3Bharath Rupireddy
bharath.rupireddyforpostgres@gmail.com
In reply to: Daniel Gustafsson (#2)
Re: Remove extra Logging_collector check before calling SysLogger_Start()

On Fri, Dec 3, 2021 at 1:43 PM Daniel Gustafsson <daniel@yesql.se> wrote:

On 3 Dec 2021, at 08:58, Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com> wrote:

It seems like there's an extra Logging_collector check before calling
SysLogger_Start(). Note that the SysLogger_Start() has a check to
return 0 if Logging_collector is off. This change is consistent with
the other usage of SysLogger_Start().

/* If we have lost the log collector, try to start a new one */
-               if (SysLoggerPID == 0 && Logging_collector)
+               if (SysLoggerPID == 0)
SysLoggerPID = SysLogger_Start();

I think the code reads clearer with the Logging_collector check left intact,
and avoiding a function call in this codepath doesn't hurt.

In that case, can we remove if (!Logging_collector) within
SysLogger_Start() and have the check outside? This will save function
call costs in the other places too. The pgarch_start and
AutoVacuumingActive have checks outside PgArchStartupAllowed and
AutoVacuumingActive.

Regards,
Bharath Rupireddy.

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bharath Rupireddy (#3)
Re: Remove extra Logging_collector check before calling SysLogger_Start()

Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com> writes:

On Fri, Dec 3, 2021 at 1:43 PM Daniel Gustafsson <daniel@yesql.se> wrote:

On 3 Dec 2021, at 08:58, Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com> wrote:

It seems like there's an extra Logging_collector check before calling
SysLogger_Start().

I think the code reads clearer with the Logging_collector check left intact,
and avoiding a function call in this codepath doesn't hurt.

In that case, can we remove if (!Logging_collector) within
SysLogger_Start() and have the check outside?

I think it's fine as-is; good belt-and-suspenders-too programming.
It's not like the extra check inside SysLogger_Start() is costly.

regards, tom lane

#5Michael Paquier
michael@paquier.xyz
In reply to: Tom Lane (#4)
Re: Remove extra Logging_collector check before calling SysLogger_Start()

On Fri, Dec 03, 2021 at 12:45:34PM -0500, Tom Lane wrote:

I think it's fine as-is; good belt-and-suspenders-too programming.
It's not like the extra check inside SysLogger_Start() is costly.

+1.
--
Michael