Skip to content

Commit 804e554

Browse files
[DPE-6675] Add wal_keep_size config option (#892)
* Add wal_keep_size config option Signed-off-by: Marcelo Henrique Neppel <[email protected]> * Validate config option value Signed-off-by: Marcelo Henrique Neppel <[email protected]> --------- Signed-off-by: Marcelo Henrique Neppel <[email protected]>
1 parent 23a1252 commit 804e554

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
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
@@ -1965,6 +1965,7 @@ def update_config(self, is_creating_backup: bool = False) -> bool:
19651965
"max_connections": max_connections,
19661966
"max_prepared_transactions": self.config.memory_max_prepared_transactions,
19671967
"shared_buffers": self.config.memory_shared_buffers,
1968+
"wal_keep_size": self.config.durability_wal_keep_size,
19681969
})
19691970

19701971
self._handle_postgresql_restart_need()

src/config.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class CharmConfig(BaseConfigModel):
2121
connection_statement_timeout: int | None
2222
cpu_parallel_leader_participation: bool | None
2323
durability_synchronous_commit: str | None
24+
durability_wal_keep_size: int | None
2425
experimental_max_connections: int | None
2526
instance_default_text_search_config: str | None
2627
instance_max_locks_per_transaction: int | None
@@ -203,6 +204,15 @@ def durability_synchronous_commit_values(cls, value: str) -> str | None:
203204

204205
return value
205206

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

0 commit comments

Comments
 (0)