Skip to content

Commit 9af8b54

Browse files
authored
Fix handling of non-transient errors when processing doc-compare tasks. (#123)
Previously errors in task verification triggered warnings, but not actual errors. This fixes that.
1 parent 916bad0 commit 9af8b54

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

internal/verifier/migration_verifier.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,9 +528,9 @@ func (verifier *Verifier) ProcessVerifyTask(ctx context.Context, workerNum int,
528528
var bytesCount types.ByteCount
529529
var err error
530530

531-
// Recheck tasks
532531
if task.IsRecheck() {
533-
idGroups, err := util.SplitArrayByBSONMaxSize(task.Ids, int(verifier.recheckMaxSizeInBytes))
532+
var idGroups [][]any
533+
idGroups, err = util.SplitArrayByBSONMaxSize(task.Ids, int(verifier.recheckMaxSizeInBytes))
534534
if err != nil {
535535
return errors.Wrapf(err, "failed to split recheck task %v document IDs", task.PrimaryKey)
536536
}

internal/verifier/migration_verifier_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,37 @@ func TestIntegration(t *testing.T) {
6868
suite.Run(t, testSuite)
6969
}
7070

71+
func (suite *IntegrationTestSuite) TestProcessVerifyTask_Failure() {
72+
verifier := suite.BuildVerifier()
73+
ctx := suite.Context()
74+
t := suite.T()
75+
76+
dbName := suite.DBNameForTest()
77+
collName := "coll"
78+
79+
namespace := dbName + "." + collName
80+
81+
task := &VerificationTask{
82+
PrimaryKey: primitive.NewObjectID(),
83+
QueryFilter: QueryFilter{
84+
Partition: &partitions.Partition{
85+
Key: partitions.PartitionKey{
86+
Lower: 123,
87+
},
88+
Upper: 234,
89+
},
90+
Namespace: namespace,
91+
To: namespace,
92+
},
93+
}
94+
95+
err := verifier.ProcessVerifyTask(ctx, 12, task)
96+
97+
expectedIDHex := task.PrimaryKey.Hex()
98+
99+
assert.ErrorContains(t, err, expectedIDHex)
100+
}
101+
71102
func (suite *IntegrationTestSuite) TestVerifier_DocFilter_ObjectID() {
72103
verifier := suite.BuildVerifier()
73104
ctx := suite.Context()

0 commit comments

Comments
 (0)