logicalreplica

package
v3.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 8, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ReasonRestartPending = "RestartPending"
)

Reasons reported by PrimaryReadinessQuery, rendered by PrimaryReadinessMessage.

View Source
const (
	// ReplicationUser must match v2.UserLogicalReplication.
	ReplicationUser = "logicalrepl"
)

Variables

This section is empty.

Functions

func DisableOnErrorSQL

func DisableOnErrorSQL(replica, db string) string

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

func ParsePrimaryReadinessReasons(stdout string) []string

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

func PrimaryReadinessMessage(reason string) string

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 PublicationName(replica, db string) string

func SlotName

func SlotName(replica, db string) string

Names of the replication objects backing database db of a logical replica.

func SubscriptionName

func SubscriptionName(replica, db string) string

func SubscriptionsEnabledQuery

func SubscriptionsEnabledQuery(replica string, databases []string) string

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL