Skip to content

Commit d35b18d

Browse files
[DPE-6572] Add wal_keep_size config option (#799)
* Add wal_keep_size config option Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com> * Remove parameter addition Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com> * Reset durability_wal_keep_size value to PG default Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com> --------- Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
1 parent 6677560 commit d35b18d

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ options:
3232
crashes and there are replicas.
3333
type: string
3434
default: "on"
35+
durability_wal_keep_size:
36+
description: |
37+
Sets the minimum size of the WAL file to be kept for the replication.
38+
Allowed values are: from 0 to 2147483647.
39+
type: int
40+
default: 4096
3541
experimental_max_connections:
3642
type: int
3743
description: |

src/charm.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1919,6 +1919,7 @@ def update_config(self, is_creating_backup: bool = False, no_peers: bool = False
19191919
self._patroni.bulk_update_parameters_controller_by_patroni({
19201920
"max_connections": max_connections,
19211921
"max_prepared_transactions": self.config.memory_max_prepared_transactions,
1922+
"wal_keep_size": self.config.durability_wal_keep_size,
19221923
})
19231924

19241925
self._handle_postgresql_restart_need(enable_tls)

src/config.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class CharmConfig(BaseConfigModel):
2323
connection_statement_timeout: int | None
2424
cpu_parallel_leader_participation: bool | None
2525
durability_synchronous_commit: str | None
26+
durability_wal_keep_size: int | None
2627
experimental_max_connections: int | None
2728
instance_default_text_search_config: str | None
2829
instance_max_locks_per_transaction: int | None
@@ -205,6 +206,15 @@ def durability_synchronous_commit_values(cls, value: str) -> str | None:
205206

206207
return value
207208

209+
@validator("durability_wal_keep_size")
210+
@classmethod
211+
def durability_wal_keep_size_values(cls, value: int) -> int | None:
212+
"""Check durability_wal_keep_size config option is between 0 and 2147483647."""
213+
if value < 0 or value > 2147483647:
214+
raise ValueError("Value is not between 0 and 2147483647")
215+
216+
return value
217+
208218
@validator("instance_password_encryption")
209219
@classmethod
210220
def instance_password_encryption_values(cls, value: str) -> str | None:

tests/integration/test_db_admin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ async def test_landscape_scalable_bundle_db(ops_test: OpsTest, charm: str) -> No
4444
application_name=DATABASE_APP_NAME,
4545
num_units=DATABASE_UNITS,
4646
base=CHARM_BASE,
47-
config={"profile": "testing"},
47+
config={"durability_wal_keep_size": 0, "profile": "testing"},
4848
)
4949

5050
# Deploy and test the Landscape Scalable bundle (using this PostgreSQL charm).

0 commit comments

Comments
 (0)