Fix: Add Neo4j connection pool configuration parameters

Added configurable connection pool parameters to Neo4jDriver to fix
"network abort" and "Response write failure" errors caused by stale
connections.

Changes:
- Added max_connection_pool_size parameter (default: 200)
- Added connection_timeout parameter (default: 60s)
- Added max_connection_lifetime parameter (default: 7200s = 2hr)
- Added liveness_check_timeout parameter (default: 60s) - CRITICAL FIX
- Added connection_acquisition_timeout parameter (default: 120s)

The liveness_check_timeout=60s enables connection validation after 60s
of idle time, preventing reuse of stale connections that were closed by
the Neo4j server.

Version: graphiti-core-varming 0.23.2

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Lars Varming 2025-11-14 14:31:47 +01:00
parent 7a22236164
commit a74bdf8321
2 changed files with 24 additions and 1 deletions

View file

@ -38,11 +38,34 @@ class Neo4jDriver(GraphDriver):
user: str | None,
password: str | None,
database: str = 'neo4j',
max_connection_pool_size: int = 200,
connection_timeout: float = 60.0,
max_connection_lifetime: float = 7200.0,
liveness_check_timeout: float = 60.0,
connection_acquisition_timeout: float = 120.0,
):
"""Initialize Neo4j driver with connection pool configuration.
Args:
uri: Neo4j connection URI (bolt://, neo4j://, etc.)
user: Username for authentication
password: Password for authentication
database: Database name (default: 'neo4j')
max_connection_pool_size: Max connections per host (default: 200)
connection_timeout: Timeout for TCP connection (default: 60s)
max_connection_lifetime: Max time connection is kept (default: 7200s = 2hr)
liveness_check_timeout: Idle time before connection check (default: 60s)
connection_acquisition_timeout: Timeout to acquire connection (default: 120s)
"""
super().__init__()
self.client = AsyncGraphDatabase.driver(
uri=uri,
auth=(user or '', password or ''),
max_connection_pool_size=max_connection_pool_size,
connection_timeout=connection_timeout,
max_connection_lifetime=max_connection_lifetime,
liveness_check_timeout=liveness_check_timeout,
connection_acquisition_timeout=connection_acquisition_timeout,
)
self._database = database

View file

@ -1,7 +1,7 @@
[project]
name = "graphiti-core-varming"
description = "A temporal graph building library (Varming fork with database parameter fix)"
version = "0.23.1"
version = "0.23.2"
authors = [
{ name = "Paul Paliychuk", email = "paul@getzep.com" },
{ name = "Preston Rasmussen", email = "preston@getzep.com" },