From 44649e72d6e0ab9df8b4c1b0437884ae46fe3f82 Mon Sep 17 00:00:00 2001 From: Marcelo Henrique Neppel Date: Wed, 18 Dec 2024 17:54:22 -0300 Subject: [PATCH 1/4] Add max_locks_per_transaction config option Signed-off-by: Marcelo Henrique Neppel --- config.yaml | 8 ++++++++ src/config.py | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/config.yaml b/config.yaml index 6fb64366b2..117c1f5ea3 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: 65536 instance_password_encryption: description: | Determines the algorithm to use to encrypt the password. diff --git a/src/config.py b/src/config.py index b5f41ec5b4..3cb925299c 100644 --- a/src/config.py +++ b/src/config.py @@ -18,6 +18,7 @@ class CharmConfig(BaseConfigModel): durability_synchronous_commit: Optional[str] instance_default_text_search_config: Optional[str] + instance_max_locks_per_transaction: Optional[int] instance_password_encryption: Optional[str] logging_log_connections: Optional[bool] logging_log_disconnections: Optional[bool] @@ -129,6 +130,15 @@ def instance_password_encryption_values(cls, value: str) -> Optional[str]: return value + @validator("instance_max_locks_per_transaction") + @classmethod + def instance_max_locks_per_transaction_values(cls, value: int) -> Optional[int]: + """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) -> Optional[int]: From 3fa85b36684c60963b9d91c2d10c25ba358db746 Mon Sep 17 00:00:00 2001 From: Marcelo Henrique Neppel Date: Thu, 9 Jan 2025 11:54:09 -0300 Subject: [PATCH 2/4] Fix default value for max_locks_per_transaction Signed-off-by: Marcelo Henrique Neppel --- config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.yaml b/config.yaml index 117c1f5ea3..c7f715ed15 100644 --- a/config.yaml +++ b/config.yaml @@ -24,7 +24,7 @@ options: If this value is specified without units, it is taken as kilobytes. Allowed values are: from 64 to 2147483647. type: int - default: 65536 + default: 64 instance_password_encryption: description: | Determines the algorithm to use to encrypt the password. From 5a6a9a0f1a3c517bcdf61983b8e9a2d5ac7bc9f5 Mon Sep 17 00:00:00 2001 From: Marcelo Henrique Neppel Date: Thu, 9 Jan 2025 14:01:54 -0300 Subject: [PATCH 3/4] Test new config option Signed-off-by: Marcelo Henrique Neppel --- tests/integration/test_config.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/integration/test_config.py b/tests/integration/test_config.py index 9fe542b0cd..e056e2704e 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"] + }, { "instance_password_encryption": [test_string, "scram-sha-256"] }, # config option is one of `md5` or `scram-sha-256` From 8844102c2fe5d30e430d4c04240b5879d6d319a8 Mon Sep 17 00:00:00 2001 From: Marcelo Henrique Neppel Date: Thu, 9 Jan 2025 14:14:49 -0300 Subject: [PATCH 4/4] Add comment Signed-off-by: Marcelo Henrique Neppel --- tests/integration/test_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/test_config.py b/tests/integration/test_config.py index e056e2704e..8a8aea6156 100644 --- a/tests/integration/test_config.py +++ b/tests/integration/test_config.py @@ -35,7 +35,7 @@ async def test_config_parameters(ops_test: OpsTest) -> None: }, # 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`