Skip to content

fix: handle empty CurrentPrimary in isStreamingAvailable#65

Merged
Agalin merged 1 commit into
operasoftware:mainfrom
ermakov-oleg:fix/streaming-available-check
May 20, 2026
Merged

fix: handle empty CurrentPrimary in isStreamingAvailable#65
Agalin merged 1 commit into
operasoftware:mainfrom
ermakov-oleg:fix/streaming-available-check

Conversation

@ermakov-oleg

Copy link
Copy Markdown

Summary

Port of upstream #604

Problem: When a brand-new cluster is starting, cluster.Status.CurrentPrimary is an empty string until the first pod becomes primary. The isStreamingAvailable() function did not handle this case — it fell through to logic that assumed a non-empty primary name, potentially returning incorrect results and causing WAL archiving attempts before the cluster is ready.

Fix: Added an early return false when CurrentPrimary == "", explicitly handling the bootstrapping phase. Streaming replication cannot be available if no primary has been elected yet.

@ermakov-oleg ermakov-oleg force-pushed the fix/streaming-available-check branch from c8846cf to afbf18d Compare February 13, 2026 22:52
Port of upstream PR cloudnative-pg#604. When CurrentPrimary is empty (first instance),
streaming is not available — prevents incorrect WAL predictions with
custom segment sizes during restore.

Signed-off-by: ermakov-oleg <ermakovolegs@gmail.com>

@Agalin Agalin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. I'm pretty sure the early archival try is safe (we actually run databases with bigger WAL segments in production). Still worth fixing.

@Agalin Agalin merged commit 79108f0 into operasoftware:main May 20, 2026
1 check passed
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