Schema sync label count query exhausts memory on large graphs when statistics are disabled

Open
#2,193 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
20/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
typescript
Domain
databases

Research direction

Start with the affected templates in packages/graph-explorer/src/connector/gremlin/fetchSchema/ and the fetchEdgeLabels and fetchVerticesSchema paths in index.ts. Reproduce the failure with g.E().groupCount().by(label) against a large Neptune graph with statistics disabled, then inspect the equivalent schema queries for the other supported query languages. Done means schema synchronization completes on large graphs without unbounded aggregation failures; the issue states that this work is internal and not accepting external contributions.

Written by the indexing model from the issue text.

Description

internal needs-triage performance reliability schema

Description

Gremlin schema sync fetches edge labels and their counts with a single unbounded aggregation:

g.E().groupCount().by(label)

On a large graph this exhausts Neptune's memory and the whole schema sync fails, so the connection never becomes usable. This is worse than a Schema View problem, because nothing downstream of schema sync can run.

Measured on one Neptune 1.3.5.0 db.t3.medium with DFE enabled and statistics disabled:

Graph size Result
57,538 edges succeeds in about 1.2s, fully native per its explain plan
1,057,538 edges MemoryLimitExceededException in under 10s

This code path only runs when the summary API is unavailable, which on Neptune means statistics are disabled. When the summary API works, fetchSchema takes the summary path and never issues this query. That narrows the blast radius considerably, and I have not checked how common the disabled case is in practice.

Two things I did not measure but expect to share the defect:

  • vertexLabelsTemplate is g.V().groupCount().by(label), the same shape, so a graph with a comparable number of vertices should fail the same way.
  • openCypher (MATCH ()-[e]-() RETURN type(e) AS label, count(*) AS count) and SPARQL have equivalent unbounded count queries.

Affected files:

  • packages/graph-explorer/src/connector/gremlin/fetchSchema/edgeLabelsTemplate.ts
  • packages/graph-explorer/src/connector/gremlin/fetchSchema/vertexLabelsTemplate.ts
  • packages/graph-explorer/src/connector/gremlin/fetchSchema/index.ts (fetchEdgeLabels, fetchVerticesSchema)

Environment

  • OS: N/A (server-side query failure)
  • Browser: N/A
  • Graph Explorer Version: 3.2.2, and this predates it
  • Graph Database & Version: Amazon Neptune 1.3.5.0, db.t3.medium, DFE enabled, cluster statistics disabled

Steps to Reproduce

  1. Use a Neptune cluster with statistics disabled, so the summary API returns BadRequestException.
  2. Load roughly 1M edges.
  3. Connect with Gremlin and synchronize the connection.
  4. Schema sync fails. Running g.E().groupCount().by(label) directly returns MemoryLimitExceededException.

Expected Behavior

Schema sync completes on a large graph whether or not statistics are enabled. The label and count discovery needs to be bounded, most likely by chunking per label rather than aggregating the whole edge store in one request.

Related Issues

Related: #2141 (found while investigating it; the fix there does not touch this query), #1677

[!IMPORTANT]
Internal only — this issue is maintained by the core team and is not accepting external contributions.

Dominant language
TypeScript
Stars
481
Forks
110
Avg merge
2d 14h
Merged PRs (30d)
9

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from aws/graph-explorer

All issues in aws/graph-explorer

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.