-
Notifications
You must be signed in to change notification settings - Fork 3
Fix silent table exclusion in schema-diff and repset-diff #94
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a0df6ce
Fix silent table exclusion in schema-diff and repset-diff
mason-sharp 393e45d
Track per-node repset membership in repset-diff
mason-sharp a8f372d
tests: use explicit skipped table in schema-diff summary test
mason-sharp 68f638f
Update CHANGELOG.md
mason-sharp 4948535
tests: defer rows.Close and check rows.Err in test helper
mason-sharp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| // /////////////////////////////////////////////////////////////////////////// | ||
| // | ||
| // # ACE - Active Consistency Engine | ||
| // | ||
| // Copyright (C) 2023 - 2026, pgEdge (https://www.pgedge.com/) | ||
| // | ||
| // This software is released under the PostgreSQL License: | ||
| // https://opensource.org/license/postgresql | ||
| // | ||
| // /////////////////////////////////////////////////////////////////////////// | ||
|
|
||
| package diff | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "strings" | ||
|
|
||
| "github.com/pgedge/ace/pkg/logger" | ||
| ) | ||
|
|
||
| // MissingTableInfo records a table that was not found on every node. | ||
| type MissingTableInfo struct { | ||
| Table string // schema-qualified table name | ||
| PresentOn []string // node names where the table exists | ||
| MissingFrom []string // node names where the table does not exist | ||
| } | ||
|
|
||
| // FailedTableInfo records a table whose diff failed along with the reason. | ||
| type FailedTableInfo struct { | ||
| Table string // schema-qualified table name | ||
| Err error // the error that caused the failure | ||
| } | ||
|
|
||
| // DiffSummary collects per-table outcomes during a schema-diff or repset-diff | ||
| // run and prints a human-readable summary at the end. | ||
| type DiffSummary struct { | ||
| MatchedTables []string | ||
| DifferedTables []string | ||
| FailedTables []FailedTableInfo | ||
| MissingTables []MissingTableInfo | ||
| SkippedTables []string | ||
| } | ||
|
|
||
| // PrintAndFinalize logs the summary and returns an error if any tables failed. | ||
| // The label identifies the scope (e.g. "schema public" or "repset default"). | ||
| func (s *DiffSummary) PrintAndFinalize(commandName, label string) error { | ||
| total := len(s.MatchedTables) + len(s.DifferedTables) + len(s.FailedTables) + | ||
| len(s.SkippedTables) + len(s.MissingTables) | ||
| logger.Info("%s summary: %d table(s) in %s", commandName, total, label) | ||
| if len(s.MatchedTables) > 0 { | ||
| logger.Info(" %d table(s) are identical:", len(s.MatchedTables)) | ||
| for _, t := range s.MatchedTables { | ||
| logger.Info(" - %s", t) | ||
| } | ||
| } | ||
| if len(s.SkippedTables) > 0 { | ||
| logger.Info(" %d table(s) were skipped:", len(s.SkippedTables)) | ||
| for _, t := range s.SkippedTables { | ||
| logger.Info(" - %s", t) | ||
| } | ||
| } | ||
| if len(s.DifferedTables) > 0 { | ||
| logger.Warn(" %d table(s) have differences:", len(s.DifferedTables)) | ||
| for _, t := range s.DifferedTables { | ||
| logger.Warn(" - %s", t) | ||
| } | ||
| } | ||
| if len(s.MissingTables) > 0 { | ||
| logger.Warn(" %d table(s) not present on all nodes:", len(s.MissingTables)) | ||
| for _, mt := range s.MissingTables { | ||
| logger.Warn(" - %s found on [%s] but missing from [%s]", | ||
| mt.Table, | ||
| strings.Join(mt.PresentOn, ", "), | ||
| strings.Join(mt.MissingFrom, ", ")) | ||
| } | ||
| } | ||
| if len(s.FailedTables) > 0 { | ||
| logger.Error(" %d table(s) encountered errors and could not be compared:", len(s.FailedTables)) | ||
| var names []string | ||
| for _, ft := range s.FailedTables { | ||
| logger.Error(" - %s: %v", ft.Table, ft.Err) | ||
| names = append(names, ft.Table) | ||
| } | ||
| return fmt.Errorf("%d table(s) failed during %s: %v", len(s.FailedTables), commandName, names) | ||
| } | ||
|
|
||
| return nil | ||
| } |
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.