graphprotocol / graphprotocol/graph-node
Avoid 'canceling statement due to conflict with recovery'
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 3.2k
- Forks
- 1.1k
- Avg merge
- 4d 1h
- Merged PRs (30d)
- 1
Description
When graph-node uses a shard with read replicas, replication conflicts can lead to an error canceling statement due to conflict with recovery. With that error, it is generally ok to retry the query, possibly with some backoff. The retry logic should guard against queries though that take so long that they are virtually guaranteed to fail with that error. For example, a query that would take 2 minutes will almost certainly fail if the underlying deployment has a decent amount of updates.
One way to avoid this would be to retry the query not against the same replica, but against the main database, where this error cannot happen.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Trace graph-node's shard read-replica query and retry path, then inspect how PostgreSQL recovery-conflict errors are handled. Compare retrying on another replica with routing the query to the main database, while accounting for long-running queries; done means the conflict can be retried without repeatedly sending unsuitable queries to a replica.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgresql, rust
- Domain
- backend, databases
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100