Skip to content

Commit

Permalink
Avoid divide by zero when compared blocks is zero
Browse files Browse the repository at this point in the history
  • Loading branch information
robskillington committed Jun 28, 2021
1 parent 2660ca8 commit 1f1e8ef
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/dbnode/storage/repair/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,10 @@ func (r PeerMetadataComparisonResults) Aggregate() AggregatePeerMetadataComparis
result.ComparedMissingBlocks += elem.ComparedMissingBlocks
result.ComparedExtraBlocks += elem.ComparedExtraBlocks
}
if result.ComparedBlocks > 0 {
// Do not divide by zero and end up with a struct that cannot be JSON serialized.
return result
}
result.ComparedDifferingPercent = float64(result.ComparedDifferingBlocks) / float64(result.ComparedBlocks)
return result
}
Expand Down

0 comments on commit 1f1e8ef

Please sign in to comment.