Skip to content

Add replica identity check#911

Merged
kvch merged 3 commits into
mainfrom
feature-add-replication-scope-helper
Jun 29, 2026
Merged

Add replica identity check#911
kvch merged 3 commits into
mainfrom
feature-add-replication-scope-helper

Conversation

@kvch

@kvch kvch commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Description

This PR adds a new replication check for making sure replicate identity is configured correctly for replicating updates and deletes.

Example output

Correct settings

$ pgstream check --replication -c pg2pg.yaml
✔ wal_level
✔ wal2json
✔ replication_slot_headroom
✔ replication_role_attr
✔ replica_identity
ran 5 checks

Incorrect settings

$ pgstream check --replication -c pg2pg.yaml
✔ wal_level
✔ wal2json
✔ replication_slot_headroom
✔ replication_role_attr
✘ replica_identity: "myschema"."table1": REPLICA IDENTITY=default but no PRIMARY KEY; UPDATE/DELETE WAL events will be skipped — add a PRIMARY KEY, set REPLICA IDENTITY FULL, or REPLICA IDENTITY USING INDEX <unique non-partial NOT-NULL index>
✘ replica_identity: "myschema"."table2": REPLICA IDENTITY=default but no PRIMARY KEY; UPDATE/DELETE WAL events will be skipped — add a PRIMARY KEY, set REPLICA IDENTITY FULL, or REPLICA IDENTITY USING INDEX <unique non-partial NOT-NULL index>
✘ replica_identity: "myschema"."table3": REPLICA IDENTITY=default but no PRIMARY KEY; UPDATE/DELETE WAL events will be skipped — add a PRIMARY KEY, set REPLICA IDENTITY FULL, or REPLICA IDENTITY USING INDEX <unique non-partial NOT-NULL index>
✘ replica_identity: "moreschema"."table1": REPLICA IDENTITY=default but no PRIMARY KEY; UPDATE/DELETE WAL events will be skipped — add a PRIMARY KEY, set REPLICA IDENTITY FULL, or REPLICA IDENTITY USING INDEX <unique non-partial NOT-NULL index>
ran 5 checks
Related Issue(s)

Type of Change

Please select the relevant option(s):

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📚 Documentation update
  • 🔧 Refactoring (no functional changes)
  • ⚡ Performance improvement
  • 🧪 Test coverage improvement
  • 🔨 Build/CI changes
  • 🧹 Code cleanup

Testing

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

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • Code is well-commented
  • Documentation updated where necessary

Additional Notes

@kvch

kvch commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator Author

@copilot resolve the merge conflicts in this pull request

Copilot AI commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Resolved the merge conflicts in this PR in commit c961994.

Copilot finished work on behalf of kvch June 25, 2026 08:48
@kvch kvch force-pushed the feature-add-replication-scope-helper branch from c961994 to 4542409 Compare June 25, 2026 15:43
@kvch kvch changed the base branch from main to feature-config-validate-table-selections June 29, 2026 11:07
@kvch kvch force-pushed the feature-add-replication-scope-helper branch from 96f62ee to dcd631d Compare June 29, 2026 11:09
@kvch kvch changed the title More replication checks Add replica identity check Jun 29, 2026
@kvch kvch marked this pull request as ready for review June 29, 2026 11:17
@kvch kvch requested a review from exekias June 29, 2026 11:17
kvch added a commit that referenced this pull request Jun 29, 2026
#### Description

This PR adds a new `stream.TableSelection` struct to hold included and
excluded tables. This can be used
to check if a table is included in streaming.

```go
// Package-level constructor
func NewTableSelection(include, exclude []string) (TableSelection, error)

// Methods on TableSelection
func (s TableSelection) IsUnfiltered() bool
func (s TableSelection) IsTableInScope(schema, table string) bool
func (s TableSelection) Include() []string
func (s TableSelection) Exclude() []string
```

From now on, incorrect include and exclude configurations return errors
instead of silently ignoring the setting.

This change is required by #911

#### Type of Change

Please select the relevant option(s):

- [x] 🐛 Bug fix (non-breaking change that fixes an issue)
- [ ] ✨ New feature (non-breaking change that adds functionality)
- [ ] 💥 Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] 📚 Documentation update
- [x] 🔧 Refactoring (no functional changes)
- [ ] ⚡ Performance improvement
- [ ] 🧪 Test coverage improvement
- [ ] 🔨 Build/CI changes
- [ ] 🧹 Code cleanup

#### Testing

- [x] Unit tests added/updated
- [x] Integration tests added/updated
- [x] Manual testing performed
- [x] All existing tests pass

#### Checklist

- [x] Code follows project style guidelines
- [x] Self-review completed
- [x] Code is well-commented
- [x] Documentation updated where necessary

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Base automatically changed from feature-config-validate-table-selections to main June 29, 2026 13:52
@kvch

kvch commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator Author

@copilot resolve the merge conflicts in this pull request

Copilot AI commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Resolved the merge conflicts in commit 72efce2.

Copilot finished work on behalf of kvch June 29, 2026 14:08
@github-actions

Copy link
Copy Markdown

Merging this branch will decrease overall coverage

Impacted Packages Coverage Δ 🤖
github.com/xataio/pgstream/pkg/stream/preflight 46.24% (-2.35%) 👎

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/xataio/pgstream/pkg/stream/preflight/builder.go 47.22% (ø) 36 17 19
github.com/xataio/pgstream/pkg/stream/preflight/replica_identity.go 35.48% (+35.48%) 31 (+31) 11 (+11) 20 (+20) 🌟

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/pkg/stream/preflight/replica_identity_test.go

@kvch kvch merged commit a7fcd71 into main Jun 29, 2026
8 checks passed
@kvch kvch deleted the feature-add-replication-scope-helper branch June 29, 2026 14:21
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