graphprotocol / graphprotocol/graph-node

Avoid 'canceling statement due to conflict with recovery'

Open
#4,327 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Stale
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.