jackc / jackc/pgx

Add retry wrapper

Open
#701 13 comments 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs response
Dominant language
Go
Stars
14.3k
Forks
1.1k
Avg merge
6d 9h
Merged PRs (30d)
11

Description

As I saw in older issues, you don't want to implement a retry framework inside the library, because it's hard to implement it right. Because you don't know when you can retry a network error and when not. And I totally agree with you, because consistency of the data is a very important thing.
But it can be implement at the application level, because it actually knows the nature of the query: it it a read only query or it's an idempotent write and it's safe to retry it.
Many applications would benefit from the retry logic, because it adds a lot resilience to your application.

Why not to introduce some kind of a wrapper around the library, where you set all your retry settings during the initialization. And after, when you call any query you just pass a flag whether the query is retryable or not. if it's false the wrapper just call the underlying library method, if it's true it applies the retry logic on some set or errors.

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

No file, test, or entry point is named. Start by reviewing pgx's existing query methods and error behavior, then define the wrapper API, retry settings, retryable errors, and query flag; done means the design and behavior are specified well enough to implement and validate.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, postgresql
Domain
backend-api-design, database
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.