Skip to content

Commit a2fc487

Browse files
authored
Clarify reporting of change events in progress logs. (#24)
A few things can cause migration-verifier to recheck a document: 1. document is mismatched between source & destination 2. document is missing on source or destination 3. document changed on source and needs a recheck Unfortunately, the verifier’s metadata persists 2 and 3 together, such that the verifier’s progress logs can’t differentiate them. The current progress logs, though, report them all as “missing”, which can confuse users. This changeset updates the logging verbiage to be clearer that the “missing documents” totals are really “missing or changed documents”.
1 parent b76a5b8 commit a2fc487

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,8 @@ The migration-verifier is also rather resource-hungry. To mitigate this, try lim
269269
270270
- The verifier, during its first generation, may report a confusing “Mismatches found” but then report 0 problems. This is a reporting bug in mongosync; if you see it, check the documents in `migration_verification_metadata.verification_tasks` for generation 1 (not generation 0).
271271
272+
- The verifier conflates “missing” documents with change events: if it finds a document missing and receives a change event for another document, the verifier records those together in its metadata. As a result, the verifier’s reporting can cause confusion: what its log calls “missing or changed” documents aren’t, in fact, necessarily failures; they could all just be change events that are pending a recheck.
273+
272274
# Limitations
273275
274276
- The verifier’s iterative process can handle data changes while it is running, until you hit the writesOff endpoint. However, it cannot handle DDL commands. If the verifier receives a DDL change stream event (drop, dropDatabase, rename), the verification will fail. If an untracked DDL event (create, createIndexes, dropIndexes, modify) occurs, the verifier may miss the change.

internal/verifier/summary.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -73,23 +73,23 @@ func (verifier *Verifier) reportDocumentMismatches(ctx context.Context, strBuild
7373
failureTypesTable := tablewriter.NewWriter(strBuilder)
7474
failureTypesTable.SetHeader([]string{"Failure Type", "Count"})
7575

76-
contentMismatch := 0
77-
missing := 0
76+
contentMismatchCount := 0
77+
missingOrChangedCount := 0
7878
for _, task := range failedTasks {
79-
contentMismatch += len(task.FailedDocs)
80-
missing += len(task.Ids)
79+
contentMismatchCount += len(task.FailedDocs)
80+
missingOrChangedCount += len(task.Ids)
8181
}
8282

83-
failureTypesTable.Append([]string{"Documents With Differing Content", fmt.Sprintf("%v", contentMismatch)})
84-
failureTypesTable.Append([]string{"Documents Missing On Source or Dest", fmt.Sprintf("%v", missing)})
83+
failureTypesTable.Append([]string{"Documents With Differing Content", fmt.Sprintf("%v", contentMismatchCount)})
84+
failureTypesTable.Append([]string{"Missing or Changed Documents", fmt.Sprintf("%v", missingOrChangedCount)})
8585
strBuilder.WriteString("Failure summary:\n")
8686
failureTypesTable.Render()
8787

8888
mismatchedDocsTable := tablewriter.NewWriter(strBuilder)
8989
mismatchedDocsTableRows := types.ToNumericTypeOf(0, verifier.failureDisplaySize)
9090
mismatchedDocsTable.SetHeader([]string{"ID", "Cluster", "Field", "Namespace", "Details"})
9191

92-
printAll := int64(contentMismatch) < (verifier.failureDisplaySize + int64(0.25*float32(verifier.failureDisplaySize)))
92+
printAll := int64(contentMismatchCount) < (verifier.failureDisplaySize + int64(0.25*float32(verifier.failureDisplaySize)))
9393
OUTA:
9494
for _, task := range failedTasks {
9595
for _, f := range task.FailedDocs {
@@ -118,35 +118,35 @@ OUTA:
118118
mismatchedDocsTable.Render()
119119
}
120120

121-
missingDocsTable := tablewriter.NewWriter(strBuilder)
122-
missingDocsTableRows := types.ToNumericTypeOf(0, verifier.failureDisplaySize)
123-
missingDocsTable.SetHeader([]string{"Document ID", "Source NameSpace", "Destination Namespace"})
121+
missingOrChangedDocsTable := tablewriter.NewWriter(strBuilder)
122+
missingOrChangedDocsTableRows := types.ToNumericTypeOf(0, verifier.failureDisplaySize)
123+
missingOrChangedDocsTable.SetHeader([]string{"Document ID", "Source Namespace", "Destination Namespace"})
124124

125-
printAll = int64(missing) < (verifier.failureDisplaySize + int64(0.25*float32(verifier.failureDisplaySize)))
125+
printAll = int64(missingOrChangedCount) < (verifier.failureDisplaySize + int64(0.25*float32(verifier.failureDisplaySize)))
126126
OUTB:
127127
for _, task := range failedTasks {
128128
for _, _id := range task.Ids {
129-
if !printAll && missingDocsTableRows >= verifier.failureDisplaySize {
129+
if !printAll && missingOrChangedDocsTableRows >= verifier.failureDisplaySize {
130130
break OUTB
131131
}
132132

133-
missingDocsTableRows++
134-
missingDocsTable.Append([]string{
133+
missingOrChangedDocsTableRows++
134+
missingOrChangedDocsTable.Append([]string{
135135
fmt.Sprintf("%v", _id),
136136
fmt.Sprintf("%v", task.QueryFilter.Namespace),
137137
fmt.Sprintf("%v", task.QueryFilter.To),
138138
})
139139
}
140140
}
141141

142-
if missingDocsTableRows > 0 {
142+
if missingOrChangedDocsTableRows > 0 {
143143
strBuilder.WriteString("\n")
144144
if printAll {
145-
strBuilder.WriteString("All documents present in source/destination missing in destination/source:\n")
145+
strBuilder.WriteString("All documents marked missing or changed:\n")
146146
} else {
147-
strBuilder.WriteString(fmt.Sprintf("First %d documents present in source/destination missing in destination/source:\n", verifier.failureDisplaySize))
147+
strBuilder.WriteString(fmt.Sprintf("First %d documents marked missing or changed:\n", verifier.failureDisplaySize))
148148
}
149-
missingDocsTable.Render()
149+
missingOrChangedDocsTable.Render()
150150
}
151151

152152
return true, anyAreIncomplete, nil

0 commit comments

Comments
 (0)