Skip to content

Use an impossible PID in the pidfile unit test to prevent flakiness - #125

Open
andrewkroh wants to merge 1 commit into
release-1.28from
fix/pidfile-test-flake
Open

andrewkroh wants to merge 1 commit into
release-1.28from
fix/pidfile-test-flake

Conversation

@andrewkroh

Copy link
Copy Markdown

Cherry-pick of upstream cloudnative-pg/cloudnative-pg#10138.

The pidfile unit test writes PID 1234 to the pid file and expects no
such process to exist. On a CI runner that PID can belong to a real
process. When that process has a parenthesis in its name, the go-ps
parser for /proc//stat fails with "expected space in input to
match format" and the test fails.

The failure hit #124 on a change that did not touch this package. A
rerun passed. The upstream fix uses PID 5000000, which is above the
Linux kernel's maximum pid_max of 4194304, so it never matches a real
process.

…#10138)

The pidfile unit test was using PID 1234, which could match an actual
process on CI runners. When that happened, the go-ps library would
attempt to parse `/proc/1234/stat` and fail with "expected space in
input to match format" if the process name contained special characters
(e.g., parentheses or spaces).

Use PID 5000000 instead, which is above the Linux kernel's maximum
`pid_max` (4194304), guaranteeing it will never correspond to a real
process.

Flaky test trace:
https://github.com/cloudnative-pg/cloudnative-pg/actions/runs/22711464590/job/65850424794?pr=10136

Signed-off-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com>
(cherry picked from commit a073246fac8040b0f7574798c0f1d73acbf74185)
@andrewkroh
andrewkroh force-pushed the fix/pidfile-test-flake branch from f6a448b to c194bc7 Compare October 7, 2026 14:47
@andrewkroh
andrewkroh changed the base branch from main to release-1.28 October 7, 2026 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants