Skip to content

Commit 5dd4207

Browse files
author
CloudNativePG Automated Updates
committed
chore: sync API
1 parent 4f027a2 commit 5dd4207

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

pkg/api/v1/cluster_types.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,10 +1173,24 @@ const (
11731173
SynchronousReplicaConfigurationMethodAny = SynchronousReplicaConfigurationMethod("any")
11741174
)
11751175

1176+
// DataDurabilityLevel specifies how strictly to enforce synchronous replication
1177+
// when cluster instances are unavailable. Options are `required` or `preferred`.
1178+
type DataDurabilityLevel string
1179+
1180+
const (
1181+
// DataDurabilityLevelRequired means that data durability is strictly enforced
1182+
DataDurabilityLevelRequired DataDurabilityLevel = "required"
1183+
1184+
// DataDurabilityLevelPreferred means that data durability is enforced
1185+
// only when healthy replicas are available
1186+
DataDurabilityLevelPreferred DataDurabilityLevel = "preferred"
1187+
)
1188+
11761189
// SynchronousReplicaConfiguration contains the configuration of the
11771190
// PostgreSQL synchronous replication feature.
11781191
// Important: at this moment, also `.spec.minSyncReplicas` and `.spec.maxSyncReplicas`
11791192
// need to be considered.
1193+
// +kubebuilder:validation:XValidation:rule="self.dataDurability!='preferred' || ((!has(self.standbyNamesPre) || self.standbyNamesPre.size()==0) && (!has(self.standbyNamesPost) || self.standbyNamesPost.size()==0))",message="dataDurability set to 'preferred' requires empty 'standbyNamesPre' and empty 'standbyNamesPost'"
11801194
type SynchronousReplicaConfiguration struct {
11811195
// Method to select synchronous replication standbys from the listed
11821196
// servers, accepting 'any' (quorum-based synchronous replication) or
@@ -1206,6 +1220,19 @@ type SynchronousReplicaConfiguration struct {
12061220
// only useful for priority-based synchronous replication).
12071221
// +optional
12081222
StandbyNamesPost []string `json:"standbyNamesPost,omitempty"`
1223+
1224+
// If set to "required", data durability is strictly enforced. Write operations
1225+
// with synchronous commit settings (`on`, `remote_write`, or `remote_apply`) will
1226+
// block if there are insufficient healthy replicas, ensuring data persistence.
1227+
// If set to "preferred", data durability is maintained when healthy replicas
1228+
// are available, but the required number of instances will adjust dynamically
1229+
// if replicas become unavailable. This setting relaxes strict durability enforcement
1230+
// to allow for operational continuity. This setting is only applicable if both
1231+
// `standbyNamesPre` and `standbyNamesPost` are unset (empty).
1232+
// +kubebuilder:validation:Enum=required;preferred
1233+
// +kubebuilder:default:=required
1234+
// +optional
1235+
DataDurability DataDurabilityLevel `json:"dataDurability,omitempty"`
12091236
}
12101237

12111238
// PostgresConfiguration defines the PostgreSQL configuration

0 commit comments

Comments
 (0)