Skip to content

Conversation

@eminano
Copy link
Collaborator

@eminano eminano commented Nov 12, 2025

Description

This PR updates the logic that determines if a connection error is retriable to not retry in the following cases:

  • Constraint violation errors
  • Permission denied errors
Related Issue(s)

Type of Change

  • ✨ New feature (non-breaking change that adds functionality)

Testing

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing performed
  • All existing tests pass

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves the connection retry logic by making constraint violation and permission denied errors non-retriable. It also refactors the mapError function to MapError to make it publicly accessible for use in the retry logic.

  • Adds logic to mark constraint violation and permission denied errors as non-retriable
  • Exports the mapError function as MapError for use across packages
  • Adds comprehensive test coverage for the isRetriableError function

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
internal/postgres/errors.go Exports mapError function as MapError
internal/postgres/retrier/pg_querier_retrier.go Implements non-retriable error checks for permission denied and constraint violation errors
internal/postgres/retrier/pg_querier_retrier_test.go Adds test cases for isRetriableError function covering various error types
internal/postgres/pg_utils.go Updates function call from mapError to MapError
internal/postgres/pg_tx.go Updates function calls from mapError to MapError
internal/postgres/pg_replication_conn.go Updates function calls from mapError to MapError
internal/postgres/pg_conn_pool.go Updates function calls from mapError to MapError
internal/postgres/pg_conn.go Updates function calls from mapError to MapError

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@eminano eminano enabled auto-merge November 13, 2025 11:04
@eminano eminano merged commit 67393d7 into main Nov 13, 2025
7 checks passed
@eminano eminano deleted the improve-conn-retry-error-mapping branch November 13, 2025 11:07
@github-actions
Copy link

Merging this branch will increase overall coverage

Impacted Packages Coverage Δ 🤖
github.com/xataio/pgstream/internal/postgres 24.71% (ø)
github.com/xataio/pgstream/internal/postgres/retrier 91.18% (+1.01%) 👍

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/xataio/pgstream/internal/postgres/errors.go 4.35% (ø) 23 1 22
github.com/xataio/pgstream/internal/postgres/pg_conn.go 0.00% (ø) 31 0 31
github.com/xataio/pgstream/internal/postgres/pg_conn_pool.go 0.00% (ø) 40 0 40
github.com/xataio/pgstream/internal/postgres/pg_replication_conn.go 5.88% (ø) 34 2 32
github.com/xataio/pgstream/internal/postgres/pg_tx.go 0.00% (ø) 13 0 13
github.com/xataio/pgstream/internal/postgres/pg_utils.go 44.68% (ø) 94 42 52
github.com/xataio/pgstream/internal/postgres/retrier/pg_querier_retrier.go 91.18% (+1.01%) 68 (+7) 62 (+7) 6 👍

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

Changed unit test files

  • github.com/xataio/pgstream/internal/postgres/retrier/pg_querier_retrier_test.go

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.

3 participants