From f2c522ce7a04c7043d9a8394d96cef025c8d28aa Mon Sep 17 00:00:00 2001 From: Arjun Rao Date: Thu, 8 May 2025 11:00:56 +1000 Subject: [PATCH 1/2] Allow max_connections to be configured in postgres --- config.ini.example | 1 + lightrag/kg/postgres_impl.py | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/config.ini.example b/config.ini.example index 5ff7cfbb..c6edcb60 100644 --- a/config.ini.example +++ b/config.ini.example @@ -20,3 +20,4 @@ user = your_username password = your_password database = your_database workspace = default # 可选,默认为default +max_connections = 12 \ No newline at end of file diff --git a/lightrag/kg/postgres_impl.py b/lightrag/kg/postgres_impl.py index cb302e8c..c71bc867 100644 --- a/lightrag/kg/postgres_impl.py +++ b/lightrag/kg/postgres_impl.py @@ -54,7 +54,7 @@ class PostgreSQLDB: self.password = config.get("password", None) self.database = config.get("database", "postgres") self.workspace = config.get("workspace", "default") - self.max = 12 + self.max = config.get("max_connections", 12) self.increment = 1 self.pool: Pool | None = None @@ -250,6 +250,10 @@ class ClientManager: "POSTGRES_WORKSPACE", config.get("postgres", "workspace", fallback="default"), ), + "max_connections": os.environ.get( + "POSTGRES_MAX_CONNECTIONS", + config.get("postgres", "max_connections", fallback=12), + ), } @classmethod From 6ebd76d5da03fbe86b04efbc8c7183a7aefc003c Mon Sep 17 00:00:00 2001 From: Arjun Rao Date: Fri, 9 May 2025 04:22:46 +1000 Subject: [PATCH 2/2] bugfix: convert config val to int --- lightrag/kg/postgres_impl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lightrag/kg/postgres_impl.py b/lightrag/kg/postgres_impl.py index c71bc867..e2612dc6 100644 --- a/lightrag/kg/postgres_impl.py +++ b/lightrag/kg/postgres_impl.py @@ -54,7 +54,7 @@ class PostgreSQLDB: self.password = config.get("password", None) self.database = config.get("database", "postgres") self.workspace = config.get("workspace", "default") - self.max = config.get("max_connections", 12) + self.max = int(config.get("max_connections", 12)) self.increment = 1 self.pool: Pool | None = None