Skip to content

fix: AGE label creation race condition on first ingest#353

Merged
aaronsb merged 2 commits intomainfrom
fix/age-label-race-condition
Mar 2, 2026
Merged

fix: AGE label creation race condition on first ingest#353
aaronsb merged 2 commits intomainfrom
fix/age-label-race-condition

Conversation

@aaronsb
Copy link
Owner

@aaronsb aaronsb commented Mar 2, 2026

Summary

  • Migration 058: pre-create all 47 graph labels (7 vertex, 10 static edge, 30 vocabulary edge) at schema init time
  • Add retry logic (2 attempts) in _execute_cypher for "already exists" race conditions — the existing detection logged but never retried
  • Fixes: Failed to create Source node: relation "Source" already exists on fresh install first ingest

Root cause

AGE auto-creates labels on first CREATE (s:Source {...}) via implicit DDL (CREATE TABLE). When concurrent worker threads hit an empty graph simultaneously, the DDL races and the loser gets a PostgreSQL duplicate relation error.

Test plan

  • Tear down and reinit the platform (./operator.sh init)
  • Ingest a document — should succeed without "already exists" error
  • Verify kg admin workers shows no failed jobs

aaronsb added 2 commits March 2, 2026 15:18
Migration 058 explicitly creates all 7 vertex labels, 10 static edge
labels, and 30 vocabulary edge labels before any ingestion can run.

AGE auto-creates labels on first CREATE/MERGE, but this is a DDL
operation (CREATE TABLE) that races under concurrent ingestion threads,
causing "relation 'Source' already exists" on fresh installs.
The existing code detected "already exists" as an expected race but
still raised the exception. Now retries up to 2 times with rollback
between attempts, so concurrent label auto-creation is transparent.

Defense in depth for any labels not covered by migration 058.
@aaronsb aaronsb merged commit 27d4416 into main Mar 2, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant