Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes incorrect totalCount results from pagination queries that previously relied on COUNT(*) OVER() (which produces no count when OFFSET skips all rows). It updates Postgres repository list methods to compute totals via a separate COUNT(*) query (in a consistent snapshot) and adjusts synchronization logic/tests to reflect the corrected behavior.
Changes:
- Replace
COUNT(*) OVER()window-count pagination with a separateCOUNT(*)query for multiple PostgresList*methods. - Add shared helpers to run count + data queries in a read-only, repeatable-read transaction for snapshot consistency.
- Extend test coverage for the
OFFSET >= total rowscase and update machine synchronization logic/tests to use correct totals.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| internal/repository/repotest/input_test_cases.go | Adds a regression test asserting totalCount remains correct when OFFSET skips all rows. |
| internal/repository/postgres/util.go | Introduces beginReadTx and countFromTx helpers to support correct counting and consistent snapshots. |
| internal/repository/postgres/tournament.go | Switches tournament listing to separate count query + paginated select within a read-only tx. |
| internal/repository/postgres/state_hash.go | Switches state-hash listing to separate count query + paginated select within a read-only tx. |
| internal/repository/postgres/report.go | Switches report listing to separate count query + paginated select within a read-only tx. |
| internal/repository/postgres/output.go | Switches output listing to separate count query + paginated select within a read-only tx. |
| internal/repository/postgres/match_advanced.go | Switches match-advance listing to separate count query + paginated select within a read-only tx. |
| internal/repository/postgres/match.go | Switches match listing to separate count query + paginated select within a read-only tx. |
| internal/repository/postgres/input.go | Switches input listing to separate count query + paginated select within a read-only tx. |
| internal/repository/postgres/epoch.go | Switches epoch listing to separate count query + paginated select within a read-only tx. |
| internal/repository/postgres/commitment.go | Switches commitment listing to separate count query + paginated select within a read-only tx. |
| internal/repository/postgres/application.go | Switches application listing to separate count query + paginated select within a read-only tx. |
| internal/manager/instance_test.go | Updates mock ListInputs total behavior and adds a test ensuring partial-sync scenarios are detected. |
| internal/manager/instance.go | Removes the prior pre-check workaround and adds robust first-batch validation + partial replay detection. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This reverts commit a7d5558. Proper fix will follow.
bf071e0 to
9c1bfc8
Compare
renatomaia
previously approved these changes
Mar 26, 2026
9c1bfc8 to
27f43d0
Compare
renatomaia
approved these changes
Mar 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.