K8SPG-374: handle standby lag detection errors#1462
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request enhances error handling for standby lag detection in PostgreSQL cluster replication. It introduces sentinel errors and graceful error handling for transient conditions that can occur during cluster initialization or when replication is not yet established.
Changes:
- Added sentinel errors
ErrPrimaryPodNotFoundandErrInvalidLagQueryOutputfor better error classification - Enhanced error handling in
reconcileStandbyLagto set condition status to Unknown for recoverable error scenarios - Added empty string validation before parsing lag values from database queries
- Reduced logging verbosity for periodic requeue operations
- Removed unused
fmtimport from pgbackup controller
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| percona/controller/pgcluster/standby.go | Implements improved error handling for standby lag detection with sentinel errors, graceful handling of transient conditions, and empty string validation for query outputs |
| percona/controller/pgbackup/controller.go | Removes unused fmt import (cleanup) |
Collaborator
commit: ba26542 |
egegunes
approved these changes
Feb 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://perconadev.atlassian.net/browse/K8SPG-374
DESCRIPTION
This PR improves standby lag detection by handling 2 errors that can occur when the source cluster is paused.
If the primary pod cannot be identified during lag detection, the operator sets the following condition on the
PerconaPGClusterresource:If the lag detection query returns no rows/NULL (for example, when
pg_stat_wal_receiveris empty), the operator sets the following condition on thePerconaPGClusterresource:Additionally, this PR moves the log message
"Requeuing standby cluster for lag check"fromINFOtoDEBUG.CHECKLIST
Jira
Needs Doc) and QA (Needs QA)?Tests
Config/Logging/Testability