Skip to content

Collect WAL stats metric from primary only.#9788

Open
redbaron wants to merge 1 commit into
cloudnative-pg:mainfrom
redbaron:no-wal-metric-on-replicas
Open

Collect WAL stats metric from primary only.#9788
redbaron wants to merge 1 commit into
cloudnative-pg:mainfrom
redbaron:no-wal-metric-on-replicas

Conversation

@redbaron
Copy link
Copy Markdown
Contributor

pg_stat_wal view shows WAL generation stats and only primary generates WAL.

This resolves problem where pg_stat_wal can be empty on a replica which was never a primary before, which causes metric collection to fail on a NULL conversion.

fixes #9106

@redbaron redbaron requested a review from a team as a code owner January 22, 2026 11:42
@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Jan 22, 2026
@cnpg-bot cnpg-bot added backport-requested ◀️ This pull request should be backported to all supported releases release-1.25 release-1.27 release-1.28 labels Jan 22, 2026
@github-actions
Copy link
Copy Markdown
Contributor

❗ By default, the pull request is configured to backport to all release branches.

  • To stop backporting this pr, remove the label: backport-requested ◀️ or add the label 'do not backport'
  • To stop backporting this pr to a certain release branch, remove the specific branch label: release-x.y

@dosubot dosubot Bot added bug 🐛 Something isn't working ok to merge 👌 This PR can be merged labels Jan 22, 2026
pg_stat_wal view shows WAL generation stats and only primary generates
WAL.

This resolves problem where pg_stat_wal can be empty on a replica which
was never a primary before, which causes metric collection to fail on a
NULL conversion.

Signed-off-by: Maxim Ivanov <maxim@heroiclabs.com>
@redbaron redbaron force-pushed the no-wal-metric-on-replicas branch from c1056c5 to 1987fab Compare January 22, 2026 11:42
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jan 27, 2026
@redbaron
Copy link
Copy Markdown
Contributor Author

There was 1.29 release without this fix. Could you please consider merging it for 1.29.1 or 1.30 at least?

@redbaron
Copy link
Copy Markdown
Contributor Author

@gbartolini , @jsilvela , what would it take to merge this in?

@jsilvela
Copy link
Copy Markdown
Collaborator

a second approval, @redbaron. You already have mine

@honi-at-simspace
Copy link
Copy Markdown

we are having this problem too. Can this be merged?

@honi-at-simspace
Copy link
Copy Markdown

I also put another PR to fix the underlying issue (#10624) which allows for NULL values for pg_stat_wal.stats_reset, which would resolve this issue as well as other times that it can be NULL on a primary as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-requested ◀️ This pull request should be backported to all supported releases bug 🐛 Something isn't working lgtm This PR has been approved by a maintainer ok to merge 👌 This PR can be merged release-1.25 release-1.28 release-1.29 size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: 1.27.1 stats query bug

5 participants