diff --git a/config.yaml b/config.yaml index 6fb64366b2..c7f715ed15 100644 --- a/config.yaml +++ b/config.yaml @@ -17,6 +17,14 @@ options: “pg_catalog.english”. type: string default: "pg_catalog.simple" + instance_max_locks_per_transaction: + description: | + Specifies the maximum amount of memory to be used by maintenance operations, + such as "VACUUM", "CREATE INDEX", and "ALTER TABLE ADD FOREIGN KEY". + If this value is specified without units, it is taken as kilobytes. + Allowed values are: from 64 to 2147483647. + type: int + default: 64 instance_password_encryption: description: | Determines the algorithm to use to encrypt the password. diff --git a/src/config.py b/src/config.py index 82e479b2f5..61018420ad 100644 --- a/src/config.py +++ b/src/config.py @@ -17,6 +17,7 @@ class CharmConfig(BaseConfigModel): durability_synchronous_commit: str | None instance_default_text_search_config: str | None + instance_max_locks_per_transaction: int | None instance_password_encryption: str | None logging_log_connections: bool | None logging_log_disconnections: bool | None @@ -128,6 +129,15 @@ def instance_password_encryption_values(cls, value: str) -> str | None: return value + @validator("instance_max_locks_per_transaction") + @classmethod + def instance_max_locks_per_transaction_values(cls, value: int) -> int | None: + """Check instance_max_locks_per_transaction config option is between 64 and 2147483647.""" + if value < 64 or value > 2147483647: + raise ValueError("Value is not between 64 and 2147483647") + + return value + @validator("logging_log_min_duration_statement") @classmethod def logging_log_min_duration_statement_values(cls, value: int) -> int | None: diff --git a/tests/integration/test_config.py b/tests/integration/test_config.py index 9fe542b0cd..8a8aea6156 100644 --- a/tests/integration/test_config.py +++ b/tests/integration/test_config.py @@ -33,6 +33,9 @@ async def test_config_parameters(ops_test: OpsTest) -> None: { "durability_synchronous_commit": [test_string, "on"] }, # config option is one of `on`, `remote_apply` or `remote_write` + { + "instance_max_locks_per_transaction": ["-1", "64"] + }, # config option is between 64 and 2147483647 { "instance_password_encryption": [test_string, "scram-sha-256"] }, # config option is one of `md5` or `scram-sha-256`