Skip to content

Conversation

@supmo668
Copy link
Contributor

Summary

Fixes #1079

Neo4j 5.26+ throws EquivalentSchemaRuleAlreadyExists errors when creating indices in parallel, even with IF NOT EXISTS clause. This causes Docker Compose deployments to fail on startup.

Changes

  • Added error handling in Neo4jDriver.execute_query() to catch neo4j.exceptions.ClientError
  • Specifically checks for EquivalentSchemaRuleAlreadyExists error code
  • Logs the occurrence as info instead of error
  • Returns empty result to indicate success (index/constraint already exists)

Technical Details

The race condition occurs when multiple CREATE INDEX IF NOT EXISTS queries run concurrently via semaphore_gather in build_indices_and_constraints(). Neo4j 5.26+ returns an error even though the index creation succeeds.

This solution follows the same pattern already implemented in the FalkorDB driver for handling "already indexed" errors (see FalkorDriver.execute_query() lines 177-180).

Test Plan

  • Code passes make lint (ruff + pyright)
  • Follows existing error handling pattern from FalkorDB driver
  • Integration tests require Neo4j instance (will be validated by CI)

Checklist

  • Code follows project style guidelines
  • Changes are focused on fixing the specific issue
  • Error handling is consistent with existing patterns
  • Appropriate logging added

🤖 Generated with Claude Code

Fixes getzep#1079

Neo4j 5.26+ throws EquivalentSchemaRuleAlreadyExists errors when
creating indices in parallel, even with IF NOT EXISTS clause.

This fix:
- Catches neo4j.exceptions.ClientError exceptions
- Checks for EquivalentSchemaRuleAlreadyExists error code
- Logs the occurrence as info instead of error
- Returns empty result to indicate success (index/constraint exists)

This prevents the MCP server from crashing on startup when multiple
CREATE INDEX IF NOT EXISTS queries run concurrently via semaphore_gather.

The solution follows the same pattern already implemented in the
FalkorDB driver for handling "already indexed" errors.

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

Co-Authored-By: Claude <[email protected]>
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.

[BUG] Docker Compose deployments failing with EquivalentSchemaRuleAlreadyExists on fresh Neo4j 5.26 (related to #1063)

1 participant