feat: enable failsafe mode for single-host nodes#380
feat: enable failsafe mode for single-host nodes#380jason-lynch merged 2 commits intorelease/v0.8.0from
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughAdded a public ChangesPer-Node Sizing and Failsafe Configuration
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
server/internal/database/spec.go (1)
580-601:⚠️ Potential issue | 🟠 Major | ⚡ Quick winClone drops
InPlaceRestorestate.Line 580-601:
InstanceSpec.Clone()does not copyInPlaceRestore, so cloned specs silently reset it tofalse.Proposed fix
return &InstanceSpec{ InstanceID: s.InstanceID, TenantID: utils.ClonePointer(s.TenantID), DatabaseID: s.DatabaseID, HostID: s.HostID, DatabaseName: s.DatabaseName, NodeName: s.NodeName, NodeOrdinal: s.NodeOrdinal, PgEdgeVersion: s.PgEdgeVersion.Clone(), Port: utils.ClonePointer(s.Port), PatroniPort: utils.ClonePointer(s.PatroniPort), CPUs: s.CPUs, MemoryBytes: s.MemoryBytes, DatabaseUsers: users, BackupConfig: s.BackupConfig.Clone(), RestoreConfig: s.RestoreConfig.Clone(), PostgreSQLConf: maps.Clone(s.PostgreSQLConf), ClusterSize: s.ClusterSize, NodeSize: s.NodeSize, + InPlaceRestore: s.InPlaceRestore, OrchestratorOpts: s.OrchestratorOpts.Clone(), AllHostIDs: slices.Clone(s.AllHostIDs), }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@server/internal/database/spec.go` around lines 580 - 601, InstanceSpec.Clone currently omits the InPlaceRestore field causing clones to reset that state; update the Clone implementation (the constructor returning &InstanceSpec{...}) to include the InPlaceRestore field by adding InPlaceRestore: s.InPlaceRestore (or the appropriate pointer clone if the field is a pointer) so the cloned InstanceSpec preserves the original InPlaceRestore value.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@server/internal/database/spec.go`:
- Around line 580-601: InstanceSpec.Clone currently omits the InPlaceRestore
field causing clones to reset that state; update the Clone implementation (the
constructor returning &InstanceSpec{...}) to include the InPlaceRestore field by
adding InPlaceRestore: s.InPlaceRestore (or the appropriate pointer clone if the
field is a pointer) so the cloned InstanceSpec preserves the original
InPlaceRestore value.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: fda37d05-3da5-4bd2-8d96-aaa1c3abfce8
📒 Files selected for processing (2)
server/internal/database/instance_resource.goserver/internal/database/spec.go
Patroni's failsafe mode prevents instances from going into read-only mode when they lose their connection to the DCS as long as they're able to contact all other Patroni instances in the cluster. There could be edge-cases to this behavior when there's more than one instance in the Patroni cluster, however it's known to be safe if there's only one host in cluster. This commit enables failsafe mode when there's only a single host in the node (meaning the Patroni cluster only has a single instance) and disables it otherwise. This change is backward-compatible and does not need a migration. PLAT-545
0fa0123 to
7d83404
Compare
7d83404 to
3a368c3
Compare
Summary
Patroni's failsafe mode prevents instances from entering read-only mode when they lose their connection to the DCS, as long as they can contact all other Patroni instances in the cluster. There could be edge cases to this behavior when there's more than one instance in the Patroni cluster; however, it's known to be safe if there's only one host in the cluster.
This commit enables failsafe mode when there's only a single host in the node (meaning the Patroni cluster only has a single instance) and disables it otherwise.
This change is backward-compatible and does not need a migration.
Testing
PLAT-545