Skip to content

Commit 0ef7866

Browse files
committed
Merge branch 'felipe_air_france_typos' into felipe_read_docs_parallel_redux
2 parents 432d94d + af5a0b4 commit 0ef7866

File tree

3 files changed

+35
-28
lines changed

3 files changed

+35
-28
lines changed

internal/reportutils/reportutils.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,5 +183,6 @@ func FindBestUnit[T num16Plus](count T) DataUnit {
183183
// FmtBytes is a convenience that combines BytesToUnit with FindBestUnit.
184184
// Use it to format a single count of bytes.
185185
func FmtBytes[T num16Plus](count T) string {
186-
return BytesToUnit(count, FindBestUnit(count))
186+
unit := FindBestUnit(count)
187+
return BytesToUnit(count, unit) + " " + string(unit)
187188
}

internal/verifier/check.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ func (verifier *Verifier) CheckWorker(ctxIn context.Context) error {
146146
err = nil
147147
}
148148

149-
if err != nil {
149+
if err == nil {
150150
verifier.logger.Debug().
151151
Int("generation", generation).
152152
Msgf("Check finished.")
@@ -432,11 +432,6 @@ func (verifier *Verifier) work(ctx context.Context, workerNum int) error {
432432
duration := verifier.workerSleepDelayMillis * time.Millisecond
433433

434434
if duration > 0 {
435-
verifier.logger.Debug().
436-
Int("workerNum", workerNum).
437-
Stringer("duration", duration).
438-
Msg("No tasks found. Sleeping.")
439-
440435
time.Sleep(duration)
441436
}
442437

@@ -453,6 +448,8 @@ func (verifier *Verifier) work(ctx context.Context, workerNum int) error {
453448
switch task.Type {
454449
case verificationTaskVerifyCollection:
455450
err := verifier.ProcessCollectionVerificationTask(ctx, workerNum, task)
451+
verifier.workerTracker.Unset(workerNum)
452+
456453
if err != nil {
457454
return err
458455
}
@@ -464,6 +461,8 @@ func (verifier *Verifier) work(ctx context.Context, workerNum int) error {
464461
}
465462
case verificationTaskVerifyDocuments:
466463
err := verifier.ProcessVerifyTask(ctx, workerNum, task)
464+
verifier.workerTracker.Unset(workerNum)
465+
467466
if err != nil {
468467
return err
469468
}

internal/verifier/migration_verifier.go

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -503,11 +503,16 @@ func (verifier *Verifier) getDocumentsCursor(ctx context.Context, collection *mo
503503
}
504504
}
505505
findCmd := append(bson.D{{"find", collection.Name()}}, findOptions...)
506-
verifier.logger.Debug().
507-
Interface("task", task.PrimaryKey).
508-
Str("findCmd", fmt.Sprintf("%s", findCmd)).
509-
Str("options", fmt.Sprintf("%v", *runCommandOptions)).
510-
Msg("getDocuments findCmd.")
506+
507+
// Suppress this log for recheck tasks because the list of IDs can be
508+
// quite long.
509+
if len(task.Ids) == 0 {
510+
verifier.logger.Debug().
511+
Interface("task", task.PrimaryKey).
512+
Str("findCmd", fmt.Sprintf("%s", findCmd)).
513+
Str("options", fmt.Sprintf("%v", *runCommandOptions)).
514+
Msg("getDocuments findCmd.")
515+
}
511516

512517
return collection.Database().RunCommandCursor(ctx, findCmd, runCommandOptions)
513518
}
@@ -595,16 +600,6 @@ func (verifier *Verifier) ProcessVerifyTask(ctx context.Context, workerNum int,
595600
Interface("task", task.PrimaryKey).
596601
Msg("Processing document comparison task.")
597602

598-
defer func() {
599-
elapsed := time.Since(start)
600-
601-
verifier.logger.Debug().
602-
Int("workerNum", workerNum).
603-
Interface("task", task.PrimaryKey).
604-
Stringer("timeElapsed", elapsed).
605-
Msg("Finished document comparison task.")
606-
}()
607-
608603
problems, docsCount, bytesCount, err := verifier.FetchAndCompareDocuments(
609604
ctx,
610605
task,
@@ -681,12 +676,24 @@ func (verifier *Verifier) ProcessVerifyTask(ctx context.Context, workerNum int,
681676
}
682677
}
683678

684-
return errors.Wrapf(
685-
verifier.UpdateVerificationTask(ctx, task),
686-
"failed to persist task %s's new status (%#q)",
687-
task.PrimaryKey,
688-
task.Status,
689-
)
679+
err = verifier.UpdateVerificationTask(ctx, task)
680+
681+
if err != nil {
682+
return errors.Wrapf(
683+
err,
684+
"failed to persist task %s's new status (%#q)",
685+
task.PrimaryKey,
686+
task.Status,
687+
)
688+
}
689+
690+
verifier.logger.Debug().
691+
Int("workerNum", workerNum).
692+
Interface("task", task.PrimaryKey).
693+
Stringer("timeElapsed", time.Since(start)).
694+
Msg("Finished document comparison task.")
695+
696+
return nil
690697
}
691698

692699
func (verifier *Verifier) logChunkInfo(ctx context.Context, namespaceAndUUID *uuidutil.NamespaceAndUUID) {

0 commit comments

Comments
 (0)