Skip to content

fix: bound ArangoDB connection check with an explicit timeout#149

Open
Logaka wants to merge 13 commits into
mainfrom
fix/arango-connection
Open

fix: bound ArangoDB connection check with an explicit timeout#149
Logaka wants to merge 13 commits into
mainfrom
fix/arango-connection

Conversation

@Logaka

@Logaka Logaka commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Problem

checkConnection() runs a synchronous RETURN 42 query. Under the hood the ArangoDB driver blocks on CompletableFuture.get() with no deadline. When a pooled connection goes stale — TCP stays open but the server stops responding, e.g. during a cluster failover — the call blocks forever. The driver's timeout
setting only covers connection establishment, not in-flight requests over an already-pooled connection.

Fix

  • Run the check query on a daemon ExecutorService and cap it with future.get(timeout, ...); on TimeoutException, cancel and return false. Applied in both ArangoDatabaseProvider (base) and DbaasArangoTemplate (starter).
  • Wire the existing dbaas.arangodb.timeout property through ServiceDbaasArangoConfiguration / TenantDbaasArangoConfiguration into ArangoDatabaseProvider via a new constructor arg (.filter(t -> t > 0), default 60s) — so the path that actually hung is now configurable, consistent with DbaasArangoTemplate.

Tests

  • StaleCachedConnectionHangTest — two-phase TCP proxy: completes a real ArangoDB handshake, then goes silent while keeping TCP alive; asserts provide() no longer hangs.
  • CheckConnectionTimeoutTest — black-hole server; both DbaasArangoTemplate.query() and ArangoDatabaseProvider.provide() paths.
  • Fixed a regression in the existing DbaasArangoTemplateTest (NPE — checkConnection now reads dbaasArangoConfig, unset on the CALLS_REAL_METHODS mock).

checkConnection() ran a synchronous "RETURN 42" query whose underlying
CompletableFuture.get() has no deadline. When a pooled connection goes
stale (silent TCP, e.g. cluster failover) the call blocked forever — the
driver's socket timeout only covers connection establishment, not
in-flight requests. In production this pinned the synchronized health
service monitor, blocking all Tomcat workers and failing readiness.

Run the check on a daemon executor and cap it with future.get(timeout).
Wire the existing dbaas.arangodb.timeout property through
Service/TenantDbaasArangoConfiguration into ArangoDatabaseProvider via a
new constructor arg (default 60s). Fix DbaasArangoTemplateTest which
NPE'd now that checkConnection reads dbaasArangoConfig.
@Logaka
Logaka requested a review from lis0x90 as a code owner July 21, 2026 12:11
@github-actions github-actions Bot added the bug Something isn't working label Jul 21, 2026
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants