Documentation
¶
Index ¶
- Constants
- func DisableOnErrorSQL(replica, db string) string
- func Enabled(inCluster *v1beta1.PostgresCluster) bool
- func IgnoreSlotsMatchers(inCluster *v1beta1.PostgresCluster) []any
- func ParsePrimaryReadinessReasons(stdout string) []string
- func PostgreSQLHBAs(inCluster *v1beta1.PostgresCluster, outHBAs *postgres.HBAs)
- func PrimaryReadinessMessage(reason string) string
- func PrimaryReadinessQuery() string
- func PublicationName(replica, db string) string
- func SlotName(replica, db string) string
- func SubscriptionName(replica, db string) string
- func SubscriptionsEnabledQuery(replica string, databases []string) string
Constants ¶
const (
ReasonRestartPending = "RestartPending"
)
Reasons reported by PrimaryReadinessQuery, rendered by PrimaryReadinessMessage.
const (
// ReplicationUser must match v2.UserLogicalReplication.
ReplicationUser = "logicalrepl"
)
Variables ¶
This section is empty.
Functions ¶
func DisableOnErrorSQL ¶
DisableOnErrorSQL returns the statement that puts the subscription of database db on the given logical replica into "disable_on_error" mode.
pg_createsubscriber has no option for this and it is a per-subscription option rather than a server setting. Without it a single conflicting row leaves the apply worker retrying forever while its slot pins WAL on the primary.
func Enabled ¶
func Enabled(inCluster *v1beta1.PostgresCluster) bool
Enabled returns whether the cluster has any logical replica configured.
func IgnoreSlotsMatchers ¶
func IgnoreSlotsMatchers(inCluster *v1beta1.PostgresCluster) []any
IgnoreSlotsMatchers returns the Patroni "ignore_slots" entries that keep it from deleting the logical replication slots backing the logical replicas. Patroni drops slots it does not know about regardless of "use_slots", so without this the slot pg_createsubscriber leaves behind dies on the next HA loop.
The matcher deliberately carries no name: slot names are only known once the databases of a replica have been resolved, which happens after this configuration has been rendered. Matching every logical pgoutput slot is stable from the moment a logical replica appears in the spec.
func ParsePrimaryReadinessReasons ¶
ParsePrimaryReadinessReasons reads the output of PrimaryReadinessQuery. A nil result means the primary satisfies every prerequisite.
func PostgreSQLHBAs ¶
func PostgreSQLHBAs(inCluster *v1beta1.PostgresCluster, outHBAs *postgres.HBAs)
PostgreSQLHBAs provides the Postgres HBA rules that let a logical replica and the tools that build it reach the primary as ReplicationUser.
func PrimaryReadinessMessage ¶
PrimaryReadinessMessage renders one of the reasons above as a sentence for a condition message.
func PrimaryReadinessQuery ¶
func PrimaryReadinessQuery() string
PrimaryReadinessQuery returns a query whose single column lists, comma separated, every prerequisite of a logical replica bootstrap that the primary does not yet satisfy. An empty result means it satisfies all of them.
The pg_hba check is load-bearing beyond itself: patroni.DynamicConfiguration is the only writer of pg_hba.conf and it carries ignore_slots in the same map, so a rule on disk proves ignore_slots reached Patroni too.
func PublicationName ¶
func SubscriptionName ¶
func SubscriptionsEnabledQuery ¶
SubscriptionsEnabledQuery returns a query that yields "t" only when every subscription of the given replica is present and enabled. The bootstrap sets disable_on_error on all of them, so a disabled subscription is what an apply error looks like from the outside.
One connection covers every database: unlike most catalogs, pg_subscription is shared across the databases of a cluster.
Types ¶
This section is empty.