Skip to content

fix(reconcile): retry retryable Neo4j errors when creating constraints - #12

Merged
rahlk merged 1 commit into
mainfrom
fix/issue-11-constraint-retry
Sep 6, 2026
Merged

fix(reconcile): retry retryable Neo4j errors when creating constraints#12
rahlk merged 1 commit into
mainfrom
fix/issue-11-constraint-retry

Conversation

@rahlk

@rahlk rahlk commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator

Closes #11.

Release run 34004180477 failed at the gate with create constraint: Neo.TransientError.Transaction.DeadlockDetected: BoltStore.createConstraints used autocommit session.Run and returned the first error, so a retryable transient error from two concurrent writers (in CI, internal/reconcile and tests in parallel against one service; in production, two caniac --emit neo4j processes) aborted the generation.

Each CREATE CONSTRAINT ... IF NOT EXISTS now runs inside session.ExecuteWrite, so the driver retries retryable errors with its bounded jittered backoff (MaxTransactionRetryTime, 30 s default). Non-retryable errors are still returned wrapped before any data write; the session close-error handling is unchanged. Neo4j 5 accepts schema commands in a managed transaction (probed live).

Tests: three unit cases through a fake driver/session against the real createConstraints (retry after deadlock succeeds with zero autocommit calls; non-retryable error returned once, no retry; cancelled context stops). RED before the fix on the first and third. Five consecutive parallel go test ./internal/reconcile ./tests runs and one go test ./... green against a live Neo4j 5; gofmt, go vet, git diff --check clean.

Known trade-off: an unreachable server during constraint creation now waits up to the driver's retry window before failing.

@rahlk
rahlk merged commit 927a45b into main Sep 6, 2026
4 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.

Transient Neo4j deadlock on constraint creation aborts the generation (release gate)

1 participant