Skip to content

Commit da99280

Browse files
Add max_locks_per_transaction config option (#718)
Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
1 parent 9d537d4 commit da99280

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ options:
1717
“pg_catalog.english”.
1818
type: string
1919
default: "pg_catalog.simple"
20+
instance_max_locks_per_transaction:
21+
description: |
22+
Specifies the maximum amount of memory to be used by maintenance operations,
23+
such as "VACUUM", "CREATE INDEX", and "ALTER TABLE ADD FOREIGN KEY".
24+
If this value is specified without units, it is taken as kilobytes.
25+
Allowed values are: from 64 to 2147483647.
26+
type: int
27+
default: 64
2028
instance_password_encryption:
2129
description: |
2230
Determines the algorithm to use to encrypt the password.

src/config.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class CharmConfig(BaseConfigModel):
2020

2121
durability_synchronous_commit: str | None
2222
instance_default_text_search_config: str | None
23+
instance_max_locks_per_transaction: int | None
2324
instance_password_encryption: str | None
2425
logging_log_connections: bool | None
2526
logging_log_disconnections: bool | None
@@ -131,6 +132,15 @@ def instance_password_encryption_values(cls, value: str) -> str | None:
131132

132133
return value
133134

135+
@validator("instance_max_locks_per_transaction")
136+
@classmethod
137+
def instance_max_locks_per_transaction_values(cls, value: int) -> int | None:
138+
"""Check instance_max_locks_per_transaction config option is between 64 and 2147483647."""
139+
if value < 64 or value > 2147483647:
140+
raise ValueError("Value is not between 64 and 2147483647")
141+
142+
return value
143+
134144
@validator("logging_log_min_duration_statement")
135145
@classmethod
136146
def logging_log_min_duration_statement_values(cls, value: int) -> int | None:

tests/integration/test_config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ async def test_config_parameters(ops_test: OpsTest) -> None:
3737
{
3838
"durability_synchronous_commit": [test_string, "on"]
3939
}, # config option is one of `on`, `remote_apply` or `remote_write`
40+
{
41+
"instance_max_locks_per_transaction": ["-1", "64"]
42+
}, # config option is between 64 and 2147483647
4043
{
4144
"instance_password_encryption": [test_string, "scram-sha-256"]
4245
}, # config option is one of `md5` or `scram-sha-256`

0 commit comments

Comments
 (0)