Skip to content

Commit

Permalink
cherry pick pingcap#37380 to release-6.2
Browse files Browse the repository at this point in the history
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
  • Loading branch information
D3Hunter authored and ti-srebot committed Aug 26, 2022
1 parent daf2b17 commit 81ee039
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion br/pkg/lightning/restore/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -2345,7 +2345,16 @@ func (cr *chunkRestore) deliverLoop(
cr.chunk.Chunk.PrevRowIDMax = rowID

if m, ok := metric.FromContext(ctx); ok {
m.BytesCounter.WithLabelValues(metric.BytesStateRestored).Add(float64(currOffset - startOffset))
// value of currOffset comes from parser.pos which increase monotonically. the init value of parser.pos
// comes from chunk.Chunk.Offset. so it shouldn't happen that currOffset - startOffset < 0.
// but we met it one time, but cannot reproduce it now, we add this check to make code more robust
// TODO: reproduce and find the root cause and fix it completely
if currOffset >= startOffset {
m.BytesCounter.WithLabelValues(metric.BytesStateRestored).Add(float64(currOffset - startOffset))
} else {
deliverLogger.Warn("offset go back", zap.Int64("curr", currOffset),
zap.Int64("start", startOffset))
}
}

if currOffset > lastOffset || dataChecksum.SumKVS() != 0 || indexChecksum.SumKVS() != 0 {
Expand Down

0 comments on commit 81ee039

Please sign in to comment.