fix(reconcile): retry retryable Neo4j errors when creating constraints - #12
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #11.
Release run 34004180477 failed at the gate with
create constraint: Neo.TransientError.Transaction.DeadlockDetected:BoltStore.createConstraintsused autocommitsession.Runand returned the first error, so a retryable transient error from two concurrent writers (in CI,internal/reconcileandtestsin parallel against one service; in production, twocaniac --emit neo4jprocesses) aborted the generation.Each
CREATE CONSTRAINT ... IF NOT EXISTSnow runs insidesession.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 parallelgo test ./internal/reconcile ./testsruns and onego test ./...green against a live Neo4j 5;gofmt,go vet,git diff --checkclean.Known trade-off: an unreachable server during constraint creation now waits up to the driver's retry window before failing.