Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ options:
Allowed values are one of 'none', 'pl', 'all'.
Enables tracking of function call counts and time used. Specify pl to track only procedural-language functions
type: string
logical-replication-subscription-request:
description: |
Set of databases corresponding to list of tables with schema notation in JSON format, which will be requested from
publiblisher cluster to subscribe on via logical replication.
Example: {"<database>": ["<schema>.<table>", ...], ...}
type: string
# logical-replication-subscription-request:
# description: |
# Set of databases corresponding to list of tables with schema notation in JSON format, which will be requested from
# publiblisher cluster to subscribe on via logical replication.
# Example: {"<database>": ["<schema>.<table>", ...], ...}
# type: string
memory-maintenance-work-mem:
description: |
Sets the maximum memory (KB) to be used for maintenance operations.
Expand Down Expand Up @@ -912,15 +912,15 @@ options:
Enables tracking of function call counts and time used. Specify pl to track only procedural-language functions
type: string
default: "none"
logical_replication_subscription_request:
description: |
Deprecated: Use logical-replication-subscription-request instead.

Set of databases corresponding to list of tables with schema notation in JSON format, which will be requested from
publiblisher cluster to subscribe on via logical replication.
Example: {"<database>": ["<schema>.<table>", ...], ...}
type: string
default: "{}"
# logical_replication_subscription_request:
# description: |
# Deprecated: Use logical-replication-subscription-request instead.
#
# Set of databases corresponding to list of tables with schema notation in JSON format, which will be requested from
# publiblisher cluster to subscribe on via logical replication.
# Example: {"<database>": ["<schema>.<table>", ...], ...}
# type: string
# default: "{}"
memory_maintenance_work_mem:
description: |
Deprecated: Use memory-maintenance-work-mem instead.
Expand Down
14 changes: 7 additions & 7 deletions metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ provides:
interface: postgresql_async
limit: 1
optional: true
logical-replication-offer:
interface: postgresql_logical_replication
optional: true
# logical-replication-offer:
# interface: postgresql_logical_replication
# optional: true
database:
interface: postgresql_client
cos-agent:
Expand All @@ -54,10 +54,10 @@ requires:
interface: tls-certificates
limit: 1
optional: true
logical-replication:
interface: postgresql_logical_replication
limit: 1
optional: true
# logical-replication:
# interface: postgresql_logical_replication
# limit: 1
# optional: true
client-certificates:
interface: tls-certificates
limit: 1
Expand Down
22 changes: 9 additions & 13 deletions src/backups.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@
UNIT_SCOPE,
)
from relations.async_replication import REPLICATION_CONSUMER_RELATION, REPLICATION_OFFER_RELATION
from relations.logical_replication import (
LOGICAL_REPLICATION_OFFER_RELATION,
LOGICAL_REPLICATION_RELATION,
)

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -1240,15 +1236,15 @@ def _pre_restore_checks(self, event: ActionEvent) -> bool:
return False

logger.info("Checking that cluster does not have an active logical replication relation")
if self.model.get_relation(LOGICAL_REPLICATION_RELATION) or len(
self.model.relations.get(LOGICAL_REPLICATION_OFFER_RELATION, ())
):
error_message = (
"Unit cannot restore backup with an active logical replication connection"
)
logger.error(f"Restore failed: {error_message}")
event.fail(error_message)
return False
# if self.model.get_relation(LOGICAL_REPLICATION_RELATION) or len(
# self.model.relations.get(LOGICAL_REPLICATION_OFFER_RELATION, ())
# ):
# error_message = (
# "Unit cannot restore backup with an active logical replication connection"
# )
# logger.error(f"Restore failed: {error_message}")
# event.fail(error_message)
# return False

logger.info("Checking that this unit was already elected the leader unit")
if not self.charm.unit.is_leader():
Expand Down
38 changes: 17 additions & 21 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
PostgreSQLGetCurrentTimelineError,
PostgreSQLGrantDatabasePrivilegesToUserError,
PostgreSQLListUsersError,
PostgreSQLUndefinedHostError,
PostgreSQLUpdateUserPasswordError,
)
from tenacity import RetryError, Retrying, retry, stop_after_attempt, stop_after_delay, wait_fixed
Expand Down Expand Up @@ -130,10 +131,6 @@
)
from ldap import PostgreSQLLDAP
from relations.async_replication import PostgreSQLAsyncReplication
from relations.logical_replication import (
LOGICAL_REPLICATION_VALIDATION_ERROR_STATUS,
PostgreSQLLogicalReplication,
)
from relations.postgresql_provider import PostgreSQLProvider
from relations.tls import TLS
from relations.tls_transfer import TLSTransfer
Expand Down Expand Up @@ -339,7 +336,7 @@ def __init__(self, *args):
self.tls = TLS(self, PEER)
self.tls_transfer = TLSTransfer(self, PEER)
self.async_replication = PostgreSQLAsyncReplication(self)
self.logical_replication = PostgreSQLLogicalReplication(self)
# self.logical_replication = PostgreSQLLogicalReplication(self)
self.restart_manager = RollingOpsManager(
charm=self, relation="restart", callback=self._restart
)
Expand Down Expand Up @@ -1516,8 +1513,8 @@ def _on_config_changed(self, event) -> None: # noqa: C901
# Update the sync-standby endpoint in the async replication data.
self.async_replication.update_async_replication_data()

if not self.logical_replication.apply_changed_config(event):
return
# if not self.logical_replication.apply_changed_config(event):
# return

if not self.unit.is_leader():
return
Expand Down Expand Up @@ -1570,7 +1567,7 @@ def enable_disable_extensions(self, database: str | None = None) -> None:
)
self.set_unit_status(BlockedStatus(EXTENSION_OBJECT_MESSAGE))
return
except PostgreSQLEnableDisableExtensionError as e:
except (PostgreSQLEnableDisableExtensionError, PostgreSQLUndefinedHostError) as e:
logger.exception("failed to change plugins: %s", str(e))
if original_status.message == EXTENSION_OBJECT_MESSAGE:
self.set_unit_status(ActiveStatus())
Expand Down Expand Up @@ -2001,7 +1998,7 @@ def _on_update_status(self, _) -> None:

self.backup.coordinate_stanza_fields()

self.logical_replication.retry_validations()
# self.logical_replication.retry_validations()

self._set_primary_status_message()

Expand Down Expand Up @@ -2093,9 +2090,8 @@ def _can_run_on_update_status(self) -> bool:
return False

if (
self.is_blocked
and self.unit.status not in S3_BLOCK_MESSAGES
and self.unit.status.message != LOGICAL_REPLICATION_VALIDATION_ERROR_STATUS
self.is_blocked and self.unit.status not in S3_BLOCK_MESSAGES
# and self.unit.status.message != LOGICAL_REPLICATION_VALIDATION_ERROR_STATUS
):
# If charm was failing to disable plugin, try again (user may have removed the objects)
if self.unit.status.message == EXTENSION_OBJECT_MESSAGE:
Expand Down Expand Up @@ -2141,12 +2137,12 @@ def _set_primary_status_message(self) -> None:
BlockedStatus(self.app_peer_data["s3-initialization-block-message"])
)
return
if self.unit.is_leader() and (
self.app_peer_data.get("logical-replication-validation") == "error"
or self.logical_replication.has_remote_publisher_errors()
):
self.unit.status = BlockedStatus(LOGICAL_REPLICATION_VALIDATION_ERROR_STATUS)
return
# if self.unit.is_leader() and (
# self.app_peer_data.get("logical-replication-validation") == "error"
# or self.logical_replication.has_remote_publisher_errors()
# ):
# self.unit.status = BlockedStatus(LOGICAL_REPLICATION_VALIDATION_ERROR_STATUS)
# return
if (
self._patroni.get_primary(unit_name_pattern=True) == self.unit.name
or self.is_standby_leader
Expand Down Expand Up @@ -2413,7 +2409,7 @@ def update_config(
self.model.config, self.get_available_memory(), limit_memory
)

replication_slots = self.logical_replication.replication_slots()
# replication_slots = self.logical_replication.replication_slots()

# Update and reload configuration based on TLS files availability.
self._patroni.render_patroni_yml_file(
Expand All @@ -2430,7 +2426,7 @@ def update_config(
parameters=pg_parameters,
no_peers=no_peers,
user_databases_map=self.relations_user_databases_map,
slots=replication_slots,
# slots=replication_slots,
)
if no_peers:
return True
Expand Down Expand Up @@ -2464,7 +2460,7 @@ def update_config(

self._api_update_config()

self._patroni.ensure_slots_controller_by_patroni(replication_slots)
# self._patroni.ensure_slots_controller_by_patroni(replication_slots)

self._handle_postgresql_restart_need()

Expand Down
2 changes: 1 addition & 1 deletion src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class CharmConfig(BaseConfigModel):
logging_log_lock_waits: bool | None = Field(default=None)
logging_log_min_duration_statement: int | None = Field(ge=-1, le=2147483647, default=None)
logging_track_functions: Literal["none", "pl", "all"] | None = Field(default=None)
logical_replication_subscription_request: str | None
# logical_replication_subscription_request: str | None
memory_maintenance_work_mem: int | None = Field(ge=1024, le=2147483647, default=None)
memory_max_prepared_transactions: int | None = Field(ge=0, le=262143, default=None)
memory_shared_buffers: int | None = Field(ge=16, le=1073741823, default=None)
Expand Down
Loading