Avoid recalculating pgprocno in ProcArrayAdd()

Started by Shinya Kato7 months ago10 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

This thread has been committed, so CI has stopped here. Anything below is the last result it produced.

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:t53146
psql -h localhost -U postgres

Built from patchset v3 (message #3), August 12, 2026 at 01:08 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 t53146_3 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 t53146_3 && git checkout t53146_3

Patchset v3 (message #3) is on t53146_3

Jump to latest
#1Shinya Kato
shinya11.kato@gmail.com

Hi hackers,

I have fixed the issue mentioned in the subject. This was introduced
in commit 28f3915b7.

--
Best regards,
Shinya Kato
NTT OSS Center

Attachments:

v1-0001-Avoid-recalculating-pgprocno-in-ProcArrayAdd.patchapplication/octet-stream; name=v1-0001-Avoid-recalculating-pgprocno-in-ProcArrayAdd.patchDownload+1-2
#2Chao Li
li.evan.chao@gmail.com
In reply to: Shinya Kato (#1)
Re: Avoid recalculating pgprocno in ProcArrayAdd()

On Jan 22, 2026, at 13:34, Shinya Kato <shinya11.kato@gmail.com> wrote:

Hi hackers,

I have fixed the issue mentioned in the subject. This was introduced
in commit 28f3915b7.

--
Best regards,
Shinya Kato
NTT OSS Center
<v1-0001-Avoid-recalculating-pgprocno-in-ProcArrayAdd.patch>

LGTM. This is not correctness fix.

```
void
ProcArrayAdd(PGPROC *proc)
{
// GetNumberFromPGProc(proc) has been stored in a local variable
int pgprocno = GetNumberFromPGProc(proc);

// Later, the local variable should be used. This patch changes GetNumberFromPGProc(proc) to pgprocno here.
arrayP->pgprocnos[index] = GetNumberFromPGProc(proc);
```

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/

#3Shinya Kato
shinya11.kato@gmail.com
In reply to: Chao Li (#2)
Re: Avoid recalculating pgprocno in ProcArrayAdd()

On Thu, Jan 22, 2026 at 2:58 PM Chao Li <li.evan.chao@gmail.com> wrote:

<v1-0001-Avoid-recalculating-pgprocno-in-ProcArrayAdd.patch>

LGTM. This is not correctness fix.

Thank you for the review! I've updated the commit message and I'll
mark it as Ready for Committer if there are no objections.

--
Best regards,
Shinya Kato
NTT OSS Center

Attachments:

t53146_3
v2-0001-Avoid-recalculating-pgprocno-in-ProcArrayAdd.patchapplication/octet-stream; name=v2-0001-Avoid-recalculating-pgprocno-in-ProcArrayAdd.patchDownload+1-2
#4Shinya Kato
shinya11.kato@gmail.com
In reply to: Shinya Kato (#3)
Re: Avoid recalculating pgprocno in ProcArrayAdd()

On Thu, Feb 12, 2026 at 10:41 AM Shinya Kato <shinya11.kato@gmail.com> wrote:

Thank you for the review! I've updated the commit message and I'll
mark it as Ready for Committer if there are no objections.

I've marked it as Ready for committer.

--
Best regards,
Shinya Kato
NTT OSS Center

#5solai v
solai.cdac@gmail.com
In reply to: Shinya Kato (#4)
Re: Avoid recalculating pgprocno in ProcArrayAdd()

Hi all,

On Wed, Jul 1, 2026 at 4:24 PM Shinya Kato <shinya11.kato@gmail.com> wrote:

On Thu, Feb 12, 2026 at 10:41 AM Shinya Kato <shinya11.kato@gmail.com> wrote:

Thank you for the review! I've updated the commit message and I'll
mark it as Ready for Committer if there are no objections.

I've marked it as Ready for committer.

I reviewed the patch and confirmed that it replaces the redundant call
to GetNumberFromPGProc(proc) with the pre-computed pgprocno. The
change does not alter any behavior and seems to be an efficient way of
code cleanup. Patch build successfully and regression tests passed.
The patch looks good to me.

Regards,
Solai

#6Pierre Forstmann
pierre.forstmann@gmail.com
In reply to: solai v (#5)
Re: Avoid recalculating pgprocno in ProcArrayAdd()

Hello,

I have have applied the patch in a branch, rebuild (/configure --prefix=$TARGET --enable-cassert --enable-debug --with-uuid=e2fs --with-openssl --enable-tap-tests
) and installed locally postgreSQL with:

Running make check is OK but make installcheck-world fails with :

# +++ tap install-check in src/test/postmaster +++
t/001_basic.pl .............. ok
t/002_connection_limits.pl .. ok
t/003_start_stop.pl ......... ok
t/004_negotiate.pl .......... ok
All tests successful.
Files=4, Tests=67, 3 wallclock secs ( 0.01 usr 0.01 sys + 1.37 cusr 0.75 csys = 2.14 CPU)
Result: PASS
make[2] : on quitte le répertoire « /var/lib/postgresql/postgresql/src/test/postmaster »
make -C recovery installcheck
make[2] : on entre dans le répertoire « /var/lib/postgresql/postgresql/src/test/recovery »
echo "# +++ tap install-check in src/test/recovery +++" && rm -rf '/var/lib/postgresql/postgresql/src/test/recovery'/tmp_check && /usr/bin/mkdir -p '/var/lib/postgresql/postgresql/src/test/recovery'/tmp_check && cd . && TESTLOGDIR='/var/lib/postgresql/postgresql/src/test/recovery/tmp_check/log' TESTDATADIR='/var/lib/postgresql/postgresql/src/test/recovery/tmp_check' PATH="/var/lib/pgsql/local/bin:/var/lib/postgresql/postgresql/src/test/recovery:$PATH" PGPORT='65432' top_builddir='/var/lib/postgresql/postgresql/src/test/recovery/../../..' PG_REGRESS='/var/lib/postgresql/postgresql/src/test/recovery/../../../src/test/regress/pg_regress' share_contrib_dir='/var/lib/pgsql/local/share/' /usr/bin/prove -I ../../../src/test/perl/ -I . t/*.pl
# +++ tap install-check in src/test/recovery +++
t/001_stream_rep.pl ................... ok
t/002_archiving.pl .................... ok
t/003_recovery_targets.pl ............. ok
t/004_timeline_switch.pl .............. ok
t/005_replay_delay.pl ................. ok
t/006_logical_decoding.pl ............. # die: error running SQL: 'psql:<stdin>:1: ERROR: could not access file "test_decoding": No such file or directory'
# while running 'psql --no-psqlrc --no-align --tuples-only --quiet --dbname port=32144 host=/tmp/6cO_dufONc dbname='postgres' --file - --variable ON_ERROR_STOP=1' with sql 'SELECT pg_create_logical_replication_slot('test_slot', 'test_decoding');' at t/006_logical_decoding.pl line 28.
t/006_logical_decoding.pl ............. skipped: (no reason given)
t/007_sync_rep.pl ..................... ok
t/008_fsm_truncation.pl ............... ok
t/009_twophase.pl ..................... ok
t/010_logical_decoding_timelines.pl ... # die: error running SQL: 'psql:<stdin>:1: ERROR: could not access file "test_decoding": No such file or directory'
# while running 'psql --no-psqlrc --no-align --tuples-only --quiet --dbname port=20076 host=/tmp/CKHZu0kyi9 dbname='postgres' --file - --variable ON_ERROR_STOP=1' with sql 'SELECT pg_create_logical_replication_slot('before_basebackup', 'test_decoding');' at t/010_logical_decoding_timelines.pl line 52.
t/010_logical_decoding_timelines.pl ... skipped: (no reason given)
t/012_subtransactions.pl .............. ok
t/013_crash_restart.pl ................ Bailout called. Further testing stopped: pg_ctl start failed
t/013_crash_restart.pl ................ Dubious, test returned 255 (wstat 65280, 0xff00)
No subtests run

Test run interrupted!

Test Summary Report
-------------------
t/006_logical_decoding.pl (Wstat: 7424 (exited 29) Tests: 0 Failed: 0)
Non-zero exit status: 29
t/010_logical_decoding_timelines.pl (Wstat: 7424 (exited 29) Tests: 0 Failed: 0)
Non-zero exit status: 29
t/013_crash_restart.pl (Wstat: 65280 (exited 255) Tests: 0 Failed: 0)
Non-zero exit status: 255
Parse errors: No plan found in TAP output

What should I do ?

The new status of this patch is: Needs review

#7Shinya Kato
shinya11.kato@gmail.com
In reply to: Pierre Forstmann (#6)
Re: Avoid recalculating pgprocno in ProcArrayAdd()

On Mon, Aug 10, 2026 at 10:48 PM Pierre Forstmann
<pierre.forstmann@gmail.com> wrote:

Test Summary Report
-------------------
t/006_logical_decoding.pl (Wstat: 7424 (exited 29) Tests: 0 Failed: 0)
Non-zero exit status: 29
t/010_logical_decoding_timelines.pl (Wstat: 7424 (exited 29) Tests: 0 Failed: 0)
Non-zero exit status: 29
t/013_crash_restart.pl (Wstat: 65280 (exited 255) Tests: 0 Failed: 0)
Non-zero exit status: 255
Parse errors: No plan found in TAP output

What should I do ?

Thank you for testing the patch.

These failures look unrelated to the patch. The test_decoding failures
in 006 and 010 are because contrib is not present in your install
prefix. installcheck-world runs the TAP tests against the installed
tree, so "make install" alone is not enough. Please run "make
install-world" (or at least "make -C contrib install") and retry.

--
Shinya Kato
NTT OSS Center

#8Pierre Forstmann
pierre.forstmann@gmail.com
In reply to: Shinya Kato (#7)
Re: Avoid recalculating pgprocno in ProcArrayAdd()

The following review has been posted through the commitfest application:
make installcheck-world: tested, failed
Implements feature: tested, failed
Spec compliant: not tested
Documentation: not tested

I have reviewed this patch and I think it's ready for committer.

There is no SQL change and this is only an internal small code change: no need to test spec. compliance and documentation.

Regards

Pierre Forstmann

#9Pierre Forstmann
pierre.forstmann@gmail.com
In reply to: Shinya Kato (#7)
Re: Avoid recalculating pgprocno in ProcArrayAdd()

You are right: I have fixed my build script

https://github.com/pierreforstmann/pglinks/blob/main/bmake.sh

and 'make installcheck-world' does not report any test failure.

Le 12/08/2026 à 05:37, Shinya Kato a écrit :

Show quoted text

On Mon, Aug 10, 2026 at 10:48 PM Pierre Forstmann
<pierre.forstmann@gmail.com> wrote:

Test Summary Report
-------------------
t/006_logical_decoding.pl (Wstat: 7424 (exited 29) Tests: 0 Failed: 0)
Non-zero exit status: 29
t/010_logical_decoding_timelines.pl (Wstat: 7424 (exited 29) Tests: 0 Failed: 0)
Non-zero exit status: 29
t/013_crash_restart.pl (Wstat: 65280 (exited 255) Tests: 0 Failed: 0)
Non-zero exit status: 255
Parse errors: No plan found in TAP output

What should I do ?

Thank you for testing the patch.

These failures look unrelated to the patch. The test_decoding failures
in 006 and 010 are because contrib is not present in your install
prefix. installcheck-world runs the TAP tests against the installed
tree, so "make install" alone is not enough. Please run "make
install-world" (or at least "make -C contrib install") and retry.

#10Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Pierre Forstmann (#8)
Re: Avoid recalculating pgprocno in ProcArrayAdd()

On 2026-Aug-12, Pierre Forstmann wrote:

I have reviewed this patch and I think it's ready for committer.

There is no SQL change and this is only an internal small code change:
no need to test spec. compliance and documentation.

Thanks, pushed.

--
Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/
“Cuando no hay humildad las personas se degradan” (A. Christie)