Skip to content

Comments

Add retry logic to integration test catalog queries#690

Merged
eminano merged 3 commits intomainfrom
fix-flaky-integration-test
Jan 23, 2026
Merged

Add retry logic to integration test catalog queries#690
eminano merged 3 commits intomainfrom
fix-flaky-integration-test

Conversation

@eminano
Copy link
Contributor

@eminano eminano commented Jan 23, 2026

Description

This PR updates the postgres integration test helper functions that query system catalogs. They can encounter transient cache lookup failures that can occur during concurrent DDL operations. Since the catalogs are queried immediately after a DDL operation, it's likely that they will hit this issue.

This can be observed in recent CI failures, where a retry resolves the issue.

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • 🧪 Test coverage improvement

Changes Made

  • Add postgres error type for cache lookup failures
  • Add unit tests for postgres error mapping
  • Add retry logic to integration tests helper functions querying indexes and constraints

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 adds retry logic to integration test helper functions that query PostgreSQL system catalogs to handle transient cache lookup failures that can occur during concurrent DDL operations.

Changes:

  • Added new ErrCacheLookupFailed error type for PostgreSQL XX000 internal errors containing "cache lookup failed"
  • Added comprehensive unit tests for PostgreSQL error mapping
  • Updated getTableConstraints and getTableIndexes helper functions with retry logic using constant backoff

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
internal/postgres/errors.go Added ErrCacheLookupFailed error type and mapping logic for XX000 errors with "cache lookup failed" message
internal/postgres/errors_test.go Added comprehensive unit tests for error mapping, covering the new cache lookup failure case and existing error types
pkg/stream/integration/helper_test.go Added retry logic with constant backoff to getTableConstraints and getTableIndexes functions; extracted SQL queries to constants; removed unused withoutGeneratedColumn constant

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

@eminano eminano requested a review from exekias January 23, 2026 10:11
@github-actions
Copy link

Merging this branch will increase overall coverage

Impacted Packages Coverage Δ 🤖
github.com/xataio/pgstream/internal/postgres 30.00% (+3.91%) 👍
github.com/xataio/pgstream/pkg/stream/integration 0.00% (ø)

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/xataio/pgstream/internal/postgres/errors.go 65.52% (+61.67%) 29 (+3) 19 (+18) 10 (-15) 🌟

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/errors_test.go
  • github.com/xataio/pgstream/pkg/stream/integration/helper_test.go

@eminano eminano merged commit b865fd1 into main Jan 23, 2026
7 checks passed
@eminano eminano deleted the fix-flaky-integration-test branch January 23, 2026 14:29
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