Skip to content

Commit 4279431

Browse files
authored
REP-5230 Fix missing error checks. (#42)
PR #34 errantly omitted some error checks. This changeset restores those.
1 parent 25c320f commit 4279431

File tree

2 files changed

+39
-3
lines changed

2 files changed

+39
-3
lines changed

internal/verifier/compare.go

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,14 @@ func (verifier *Verifier) compareDocsFromChannels(
150150
byteCount += types.ByteCount(len(doc))
151151

152152
err = handleNewDoc(doc, true)
153+
154+
if err != nil {
155+
err = errors.Wrapf(
156+
err,
157+
"comparer thread failed to handle source doc with ID %v",
158+
doc.Lookup("_id"),
159+
)
160+
}
153161
}
154162
}
155163

@@ -164,10 +172,22 @@ func (verifier *Verifier) compareDocsFromChannels(
164172
}
165173

166174
err = handleNewDoc(doc, false)
175+
176+
if err != nil {
177+
err = errors.Wrapf(
178+
err,
179+
"comparer thread failed to handle destination doc with ID %v",
180+
doc.Lookup("_id"),
181+
)
182+
}
167183
}
168184
}
169185
}
170186

187+
if err != nil {
188+
return nil, 0, 0, errors.Wrap(err, "comparer thread failed")
189+
}
190+
171191
// We got here because both srcChannel and dstChannel are closed,
172192
// which means we have processed all documents with the same mapKey
173193
// between source & destination.
@@ -225,7 +245,15 @@ func (verifier *Verifier) getFetcherChannels(
225245
)
226246

227247
if err == nil {
228-
err = iterateCursorToChannel(ctx, cursor, srcChannel)
248+
err = errors.Wrap(
249+
iterateCursorToChannel(ctx, cursor, srcChannel),
250+
"failed to read source documents",
251+
)
252+
} else {
253+
err = errors.Wrap(
254+
err,
255+
"failed to find source documents",
256+
)
229257
}
230258

231259
return err
@@ -241,7 +269,15 @@ func (verifier *Verifier) getFetcherChannels(
241269
)
242270

243271
if err == nil {
244-
err = iterateCursorToChannel(ctx, cursor, dstChannel)
272+
err = errors.Wrap(
273+
iterateCursorToChannel(ctx, cursor, dstChannel),
274+
"failed to read destination documents",
275+
)
276+
} else {
277+
err = errors.Wrap(
278+
err,
279+
"failed to find destination documents",
280+
)
245281
}
246282

247283
return err

internal/verifier/unit_test_util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ func (suite *WithMongodsTestSuite) startReplSets() {
123123
},
124124
}
125125
err = directClient.Database("admin").RunCommand(ctx, command).Err()
126-
suite.Require().NoError(err)
126+
suite.Require().NoError(err, "should initiate replication")
127127
}
128128
}
129129

0 commit comments

Comments
 (0)