Skip to content

Commit 1cc4d7e

Browse files
[DPE-6249] Add max_locks_per_transaction config option (#804)
* Add max_locks_per_transaction config option Signed-off-by: Marcelo Henrique Neppel <[email protected]> * Fix default value for max_locks_per_transaction Signed-off-by: Marcelo Henrique Neppel <[email protected]> * Test new config option Signed-off-by: Marcelo Henrique Neppel <[email protected]> * Add comment Signed-off-by: Marcelo Henrique Neppel <[email protected]> --------- Signed-off-by: Marcelo Henrique Neppel <[email protected]>
1 parent adc54e4 commit 1cc4d7e

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
@@ -17,6 +17,7 @@ class CharmConfig(BaseConfigModel):
1717

1818
durability_synchronous_commit: str | None
1919
instance_default_text_search_config: str | None
20+
instance_max_locks_per_transaction: int | None
2021
instance_password_encryption: str | None
2122
logging_log_connections: bool | None
2223
logging_log_disconnections: bool | None
@@ -128,6 +129,15 @@ def instance_password_encryption_values(cls, value: str) -> str | None:
128129

129130
return value
130131

132+
@validator("instance_max_locks_per_transaction")
133+
@classmethod
134+
def instance_max_locks_per_transaction_values(cls, value: int) -> int | None:
135+
"""Check instance_max_locks_per_transaction config option is between 64 and 2147483647."""
136+
if value < 64 or value > 2147483647:
137+
raise ValueError("Value is not between 64 and 2147483647")
138+
139+
return value
140+
131141
@validator("logging_log_min_duration_statement")
132142
@classmethod
133143
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
@@ -33,6 +33,9 @@ async def test_config_parameters(ops_test: OpsTest) -> None:
3333
{
3434
"durability_synchronous_commit": [test_string, "on"]
3535
}, # config option is one of `on`, `remote_apply` or `remote_write`
36+
{
37+
"instance_max_locks_per_transaction": ["-1", "64"]
38+
}, # config option is between 64 and 2147483647
3639
{
3740
"instance_password_encryption": [test_string, "scram-sha-256"]
3841
}, # config option is one of `md5` or `scram-sha-256`

0 commit comments

Comments
 (0)