Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap get current LSN in txn as pgx will retry #2284

Closed
wants to merge 2 commits into from

Conversation

iskakaushik
Copy link
Contributor

Per jackc/pgx#74 (comment) moving reads into a transaction will initiate retries on network-level errors.

Per jackc/pgx#74 (comment)
moving reads into a transaction will initiate retries on network-level errors.
@iskakaushik iskakaushik requested a review from serprex November 24, 2024 16:17
if ctx.Err() != nil {
return ctx.Err()
}
time.Sleep(retryDelay)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will give an extra sleep on last try

var lsnString string
if err := tx.QueryRow(ctx, query).Scan(&lsnString); err != nil {
return 0, fmt.Errorf("query failed: %w", err)
if err := fn(tx); err != nil {
Copy link
Contributor

@serprex serprex Nov 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this accomplishes what you want still, you need to reconnect on net errors. Since retry logic of pgx exists in the pooling code

At that point there's no benefit to starting read only transaction since we aren't dealing with pooling

@serprex serprex self-requested a review November 24, 2024 17:47
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.

2 participants