Merge pull request #750 from ylacancellera/PT-2298_pt-galera-log-explainer_superfluous_lines_on_conflicts

PT-2298 pt-galera-log-explainer superfluous lines on conflicts
This commit is contained in:
Yoann La Cancellera
2024-01-26 12:36:24 +01:00
committed by GitHub
4 changed files with 26 additions and 5 deletions

View File

@@ -103,6 +103,12 @@ func TestMain(t *testing.T) {
cmd: []string{"conflicts"}, cmd: []string{"conflicts"},
path: "tests/logs/conflict/*", path: "tests/logs/conflict/*",
}, },
{
name: "conflict_list_all_no_color",
cmd: []string{"list", "--all", "--no-color"},
path: "tests/logs/conflict/*",
},
} }
TESTS: TESTS:

View File

@@ -92,14 +92,17 @@ var ApplicativeMap = types.RegexMap{
return logCtx, func(logCtx types.LogCtx) string { return logCtx, func(logCtx types.LogCtx) string {
for _, name := range logCtx.OwnNames { for _, localname := range logCtx.OwnNames {
vote, ok := latestConflict.VotePerNode[name] if node != localname {
if !ok { // don't print other nodes vote, their should be in their own column
// else it just takes too much place without adding much usability
continue continue
} }
if vote, ok := latestConflict.VotePerNode[localname]; ok {
return voteResponse(vote, *latestConflict) return voteResponse(vote, *latestConflict)
} }
}
return "" return ""
} }

View File

@@ -0,0 +1,12 @@
identifier node1
current path tests/logs/conflict/node.log
last known ip
last known name node1
mysql version
2023-10-21T04:01:01.700706Z inconsistency vote started(seqno:102573168)
consistency vote(seqno:102573168): lost
2023-10-21T04:01:01.701512Z found inconsistent by vote
2023-10-21T04:01:01.704318Z NON-PRIMARY(n=1)
2023-10-21T04:01:01.704384Z SYNCED -> OPEN
2023-10-21T04:01:01.704465Z OPEN -> CLOSED

View File

@@ -139,7 +139,7 @@ func getlasttime(l LocalTimeline) time.Time {
func CutTimelineAt(t LocalTimeline, at time.Time) LocalTimeline { func CutTimelineAt(t LocalTimeline, at time.Time) LocalTimeline {
var i int var i int
for i = 0; i < len(t); i++ { for i = 0; i < len(t); i++ {
if t[i].Date.Time.After(at) { if t[i].Date != nil && t[i].Date.Time.After(at) {
break break
} }
} }