Skip to content

ArcadeGraphManager caches stale ArcadeGraph after underlying LocalDatabase is closed and reopened — remote Gremlin traversals fail with DatabaseIsClosedException: <dbname> #5307

Closed

Description

@vivekjustthink

ArcadeDB version

26.6.1 (issue also present in current main, 26.7.1-SNAPSHOT — source confirmed)

Environment

  • Standalone ArcadeDB server, GremlinServer plugin enabled (-Darcadedb.server.plugins=GremlinServer:com.arcadedb.server.gremlin.GremlinServerPlugin)
  • Client: arcadedb-gremlin / TinkerPop 3.8.1 Java driver, connecting via AnonymousTraversalSource.traversal().withRemote(DriverRemoteConnection.using(cluster, databaseName))
  • Client also issues concurrent HTTP SQL DDL (CREATE INDEX IF NOT EXISTS ...) to the same DB during startup

Symptom

Remote Gremlin traversals against a dynamically-registered database fail with a ResponseException whose message is only the database name. Server-side arcadedb.log:

WARNI [TraversalOpProcessor] Exception processing a Traversal on iteration for request [37c16f24-…].
com.arcadedb.exception.DatabaseIsClosedException: fam
at com.arcadedb.database.LocalDatabase.checkDatabaseIsOpen(LocalDatabase.java:2155)
at com.arcadedb.database.LocalDatabase.getSchema(LocalDatabase.java:1315)
at com.arcadedb.server.ServerDatabase.getSchema(ServerDatabase.java:394)
at com.arcadedb.gremlin.ArcadeTraversalStrategy.apply(ArcadeTraversalStrategy.java:111)
at ...TraversalHelper.applyTraversalRecursively(TraversalHelper.java:739)
at ...TraversalOpProcessor.lambda$iterateBytecodeTraversal$0(TraversalOpProcessor.java:224)

The reported message is literally just the DB name because DatabaseIsClosedException(String) sets super(name).

Root cause

ArcadeGraphManager (gremlin/src/main/java/com/arcadedb/server/gremlin/ArcadeGraphManager.java) caches per-DB ArcadeGraph and TraversalSource in ConcurrentHashMaps:

private final Map<String, Graph> graphs = new ConcurrentHashMap<>();
private final Map<String, TraversalSource> traversalSources = new ConcurrentHashMap<>();

@OverRide
public TraversalSource getTraversalSource(final String name) {
TraversalSource ts = traversalSources.get(name);
if (ts == null) {
...
final Graph graph = getOrCreateArcadeGraph(dbName);
if (graph != null) { ts = graph.traversal(); traversalSources.put(name, ts); }
}
return ts; // <-- never checks whether cached graph's LocalDatabase is still open
}

ArcadeGraph.openShared(...) wraps a ServerDatabase whose wrapped field is final — it can never point at a different LocalDatabase instance.

Meanwhile ArcadeDBServer.getDatabase() (server/src/main/java/com/arcadedb/server/ArcadeDBServer.java:708) silently swaps in a new ServerDatabase when the old one is closed:
if (db == null || !db.isOpen()) {
...
embDatabase = (DatabaseInternal) (factory.exists() ? factory.open(defaultDbMode) : factory.create());
...
db = new ServerDatabase(this, embDatabase);
databases.put(databaseName, db);
}

Result: databases map holds ServerDatabase-v2 → LocalDatabase-v2 (open), but ArcadeGraphManager.graphs still holds ArcadeGraph → ServerDatabase-v1 → LocalDatabase-v1 (closed). Every subsequent Gremlin traversal
against that manager entry throws DatabaseIsClosedException.

Reproduction

  1. Start ArcadeDB with GremlinServer plugin, no pre-configured graphs for the target DB.
  2. Client: over remote-Gremlin, run any traversal against DB foo → triggers Dynamically registered database 'foo' as Gremlin graph. Works.
  3. Client: over HTTP, issue SQL DDL that causes ArcadeDB to close and reopen the foo LocalDatabase (in my case, a batch of CREATE INDEX IF NOT EXISTS on many types during app schema init reliably triggers this).
  4. Client: over remote-Gremlin, run any traversal against foo → fails with DatabaseIsClosedException: foo forever, until server restart.

Full timeline from my arcadedb.log.0:
17:14:32.945 INFO [ArcadeGraphManager] Dynamically registered database 'fam' as Gremlin graph
17:16:51.032 INFO [LSMTreeIndex] <ArcadeDB_0> Building index 'FamSequence_0_28491462620666' on FamSequence[name]...
… (further index builds) …
17:16:51.280 INFO [LSMTreeIndex] <ArcadeDB_0> Completed building index 'Media_0_...'
17:17:24.888 WARNI [TraversalOpProcessor] Exception … DatabaseIsClosedException: fam

Activity

  1. self-assigned this
    on Jul 16, 2026
  2. added theissue type on Jul 16, 2026
  3. added this to the 26.8.1 milestone on Jul 16, 2026
  4. added a commit that references this issue on Jul 16, 2026
  5. lvca commented on Jul 16, 2026

    @lvca
    Member

    Confirmed and fixed on main (will ship in the next release). Thanks for the excellent, precise report - your root-cause analysis was spot on.

    What was happening: the Gremlin server keeps a per-database cache of the graph it hands to remote traversals. If that database gets closed and reopened under the hood (for example while your app fires a burst of CREATE INDEX IF NOT EXISTS during startup), the server switches to a fresh database instance but the Gremlin cache kept pointing at the old, now-closed one. From that moment every traversal against that database failed with DatabaseIsClosedException: <dbname> until a server restart.

    The fix: the Gremlin server now notices when a cached graph points at a database that is no longer open, drops it, and transparently rebuilds it against the reopened database. No client change is needed - existing remote Gremlin connections recover on their own.

    If you can, please upgrade once the next release is out and let us know if you still see it. A regression test covering the close/reopen scenario is included so it stays fixed.

    ❤️ Thanks for helping make ArcadeDB better! ArcadeDB is free and open source, sustained by its community. If it's useful to you or your company, please consider becoming a sponsor to keep development going.

  6. added a commit that references this issue on Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions