Skip to content

Commit 910e7d9

Browse files
Disable logical replication (#1258)
* Disable logical replication relation Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com> * Disable logical replication integration tests Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com> * Disable logical replication config options Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com> * Completely disable logical replication within the charm code Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com> * Fix spread test Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com> * Catch exception to allow retry without error Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com> --------- Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
1 parent 150d98b commit 910e7d9

File tree

8 files changed

+724
-729
lines changed

8 files changed

+724
-729
lines changed

config.yaml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,12 @@ options:
100100
Allowed values are one of 'none', 'pl', 'all'.
101101
Enables tracking of function call counts and time used. Specify pl to track only procedural-language functions
102102
type: string
103-
logical-replication-subscription-request:
104-
description: |
105-
Set of databases corresponding to list of tables with schema notation in JSON format, which will be requested from
106-
publiblisher cluster to subscribe on via logical replication.
107-
Example: {"<database>": ["<schema>.<table>", ...], ...}
108-
type: string
103+
# logical-replication-subscription-request:
104+
# description: |
105+
# Set of databases corresponding to list of tables with schema notation in JSON format, which will be requested from
106+
# publiblisher cluster to subscribe on via logical replication.
107+
# Example: {"<database>": ["<schema>.<table>", ...], ...}
108+
# type: string
109109
memory-maintenance-work-mem:
110110
description: |
111111
Sets the maximum memory (KB) to be used for maintenance operations.
@@ -912,15 +912,15 @@ options:
912912
Enables tracking of function call counts and time used. Specify pl to track only procedural-language functions
913913
type: string
914914
default: "none"
915-
logical_replication_subscription_request:
916-
description: |
917-
Deprecated: Use logical-replication-subscription-request instead.
918-
919-
Set of databases corresponding to list of tables with schema notation in JSON format, which will be requested from
920-
publiblisher cluster to subscribe on via logical replication.
921-
Example: {"<database>": ["<schema>.<table>", ...], ...}
922-
type: string
923-
default: "{}"
915+
# logical_replication_subscription_request:
916+
# description: |
917+
# Deprecated: Use logical-replication-subscription-request instead.
918+
#
919+
# Set of databases corresponding to list of tables with schema notation in JSON format, which will be requested from
920+
# publiblisher cluster to subscribe on via logical replication.
921+
# Example: {"<database>": ["<schema>.<table>", ...], ...}
922+
# type: string
923+
# default: "{}"
924924
memory_maintenance_work_mem:
925925
description: |
926926
Deprecated: Use memory-maintenance-work-mem instead.

metadata.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ provides:
3636
interface: postgresql_async
3737
limit: 1
3838
optional: true
39-
logical-replication-offer:
40-
interface: postgresql_logical_replication
41-
optional: true
39+
# logical-replication-offer:
40+
# interface: postgresql_logical_replication
41+
# optional: true
4242
database:
4343
interface: postgresql_client
4444
cos-agent:
@@ -54,10 +54,10 @@ requires:
5454
interface: tls-certificates
5555
limit: 1
5656
optional: true
57-
logical-replication:
58-
interface: postgresql_logical_replication
59-
limit: 1
60-
optional: true
57+
# logical-replication:
58+
# interface: postgresql_logical_replication
59+
# limit: 1
60+
# optional: true
6161
client-certificates:
6262
interface: tls-certificates
6363
limit: 1

src/backups.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@
4444
UNIT_SCOPE,
4545
)
4646
from relations.async_replication import REPLICATION_CONSUMER_RELATION, REPLICATION_OFFER_RELATION
47-
from relations.logical_replication import (
48-
LOGICAL_REPLICATION_OFFER_RELATION,
49-
LOGICAL_REPLICATION_RELATION,
50-
)
5147

5248
logger = logging.getLogger(__name__)
5349

@@ -1240,15 +1236,15 @@ def _pre_restore_checks(self, event: ActionEvent) -> bool:
12401236
return False
12411237

12421238
logger.info("Checking that cluster does not have an active logical replication relation")
1243-
if self.model.get_relation(LOGICAL_REPLICATION_RELATION) or len(
1244-
self.model.relations.get(LOGICAL_REPLICATION_OFFER_RELATION, ())
1245-
):
1246-
error_message = (
1247-
"Unit cannot restore backup with an active logical replication connection"
1248-
)
1249-
logger.error(f"Restore failed: {error_message}")
1250-
event.fail(error_message)
1251-
return False
1239+
# if self.model.get_relation(LOGICAL_REPLICATION_RELATION) or len(
1240+
# self.model.relations.get(LOGICAL_REPLICATION_OFFER_RELATION, ())
1241+
# ):
1242+
# error_message = (
1243+
# "Unit cannot restore backup with an active logical replication connection"
1244+
# )
1245+
# logger.error(f"Restore failed: {error_message}")
1246+
# event.fail(error_message)
1247+
# return False
12521248

12531249
logger.info("Checking that this unit was already elected the leader unit")
12541250
if not self.charm.unit.is_leader():

src/charm.py

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
PostgreSQLGetCurrentTimelineError,
8080
PostgreSQLGrantDatabasePrivilegesToUserError,
8181
PostgreSQLListUsersError,
82+
PostgreSQLUndefinedHostError,
8283
PostgreSQLUpdateUserPasswordError,
8384
)
8485
from tenacity import RetryError, Retrying, retry, stop_after_attempt, stop_after_delay, wait_fixed
@@ -130,10 +131,6 @@
130131
)
131132
from ldap import PostgreSQLLDAP
132133
from relations.async_replication import PostgreSQLAsyncReplication
133-
from relations.logical_replication import (
134-
LOGICAL_REPLICATION_VALIDATION_ERROR_STATUS,
135-
PostgreSQLLogicalReplication,
136-
)
137134
from relations.postgresql_provider import PostgreSQLProvider
138135
from relations.tls import TLS
139136
from relations.tls_transfer import TLSTransfer
@@ -339,7 +336,7 @@ def __init__(self, *args):
339336
self.tls = TLS(self, PEER)
340337
self.tls_transfer = TLSTransfer(self, PEER)
341338
self.async_replication = PostgreSQLAsyncReplication(self)
342-
self.logical_replication = PostgreSQLLogicalReplication(self)
339+
# self.logical_replication = PostgreSQLLogicalReplication(self)
343340
self.restart_manager = RollingOpsManager(
344341
charm=self, relation="restart", callback=self._restart
345342
)
@@ -1516,8 +1513,8 @@ def _on_config_changed(self, event) -> None: # noqa: C901
15161513
# Update the sync-standby endpoint in the async replication data.
15171514
self.async_replication.update_async_replication_data()
15181515

1519-
if not self.logical_replication.apply_changed_config(event):
1520-
return
1516+
# if not self.logical_replication.apply_changed_config(event):
1517+
# return
15211518

15221519
if not self.unit.is_leader():
15231520
return
@@ -1570,7 +1567,7 @@ def enable_disable_extensions(self, database: str | None = None) -> None:
15701567
)
15711568
self.set_unit_status(BlockedStatus(EXTENSION_OBJECT_MESSAGE))
15721569
return
1573-
except PostgreSQLEnableDisableExtensionError as e:
1570+
except (PostgreSQLEnableDisableExtensionError, PostgreSQLUndefinedHostError) as e:
15741571
logger.exception("failed to change plugins: %s", str(e))
15751572
if original_status.message == EXTENSION_OBJECT_MESSAGE:
15761573
self.set_unit_status(ActiveStatus())
@@ -2001,7 +1998,7 @@ def _on_update_status(self, _) -> None:
20011998

20021999
self.backup.coordinate_stanza_fields()
20032000

2004-
self.logical_replication.retry_validations()
2001+
# self.logical_replication.retry_validations()
20052002

20062003
self._set_primary_status_message()
20072004

@@ -2093,9 +2090,8 @@ def _can_run_on_update_status(self) -> bool:
20932090
return False
20942091

20952092
if (
2096-
self.is_blocked
2097-
and self.unit.status not in S3_BLOCK_MESSAGES
2098-
and self.unit.status.message != LOGICAL_REPLICATION_VALIDATION_ERROR_STATUS
2093+
self.is_blocked and self.unit.status not in S3_BLOCK_MESSAGES
2094+
# and self.unit.status.message != LOGICAL_REPLICATION_VALIDATION_ERROR_STATUS
20992095
):
21002096
# If charm was failing to disable plugin, try again (user may have removed the objects)
21012097
if self.unit.status.message == EXTENSION_OBJECT_MESSAGE:
@@ -2141,12 +2137,12 @@ def _set_primary_status_message(self) -> None:
21412137
BlockedStatus(self.app_peer_data["s3-initialization-block-message"])
21422138
)
21432139
return
2144-
if self.unit.is_leader() and (
2145-
self.app_peer_data.get("logical-replication-validation") == "error"
2146-
or self.logical_replication.has_remote_publisher_errors()
2147-
):
2148-
self.unit.status = BlockedStatus(LOGICAL_REPLICATION_VALIDATION_ERROR_STATUS)
2149-
return
2140+
# if self.unit.is_leader() and (
2141+
# self.app_peer_data.get("logical-replication-validation") == "error"
2142+
# or self.logical_replication.has_remote_publisher_errors()
2143+
# ):
2144+
# self.unit.status = BlockedStatus(LOGICAL_REPLICATION_VALIDATION_ERROR_STATUS)
2145+
# return
21502146
if (
21512147
self._patroni.get_primary(unit_name_pattern=True) == self.unit.name
21522148
or self.is_standby_leader
@@ -2413,7 +2409,7 @@ def update_config(
24132409
self.model.config, self.get_available_memory(), limit_memory
24142410
)
24152411

2416-
replication_slots = self.logical_replication.replication_slots()
2412+
# replication_slots = self.logical_replication.replication_slots()
24172413

24182414
# Update and reload configuration based on TLS files availability.
24192415
self._patroni.render_patroni_yml_file(
@@ -2430,7 +2426,7 @@ def update_config(
24302426
parameters=pg_parameters,
24312427
no_peers=no_peers,
24322428
user_databases_map=self.relations_user_databases_map,
2433-
slots=replication_slots,
2429+
# slots=replication_slots,
24342430
)
24352431
if no_peers:
24362432
return True
@@ -2464,7 +2460,7 @@ def update_config(
24642460

24652461
self._api_update_config()
24662462

2467-
self._patroni.ensure_slots_controller_by_patroni(replication_slots)
2463+
# self._patroni.ensure_slots_controller_by_patroni(replication_slots)
24682464

24692465
self._handle_postgresql_restart_need()
24702466

src/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class CharmConfig(BaseConfigModel):
5252
logging_log_lock_waits: bool | None = Field(default=None)
5353
logging_log_min_duration_statement: int | None = Field(ge=-1, le=2147483647, default=None)
5454
logging_track_functions: Literal["none", "pl", "all"] | None = Field(default=None)
55-
logical_replication_subscription_request: str | None
55+
# logical_replication_subscription_request: str | None
5656
memory_maintenance_work_mem: int | None = Field(ge=1024, le=2147483647, default=None)
5757
memory_max_prepared_transactions: int | None = Field(ge=0, le=262143, default=None)
5858
memory_shared_buffers: int | None = Field(ge=16, le=1073741823, default=None)

0 commit comments

Comments
 (0)