From 02745716cadcbec8d58723868daa917e46c912f5 Mon Sep 17 00:00:00 2001 From: glorv Date: Thu, 6 May 2021 13:27:05 +0800 Subject: [PATCH] fix a bug --- pkg/lightning/restore/restore.go | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/pkg/lightning/restore/restore.go b/pkg/lightning/restore/restore.go index 7185f655f..c4708372e 100644 --- a/pkg/lightning/restore/restore.go +++ b/pkg/lightning/restore/restore.go @@ -1689,15 +1689,18 @@ func (tr *TableRestore) restoreEngine( if err == nil { metric.ChunkCounter.WithLabelValues(metric.ChunkStateFinished).Add(remainChunkCnt) metric.BytesCounter.WithLabelValues(metric.TableStateWritten).Add(float64(cr.chunk.Checksum.SumSize())) - if dataFlushStatus != nil && !dataFlushStatus.Flushed() && - indexFlushStaus != nil && !indexFlushStaus.Flushed() { - checkFlushLock.Lock() - flushPendingChunks = append(flushPendingChunks, chunkFlushStatus{ - dataStatus: dataFlushStatus, - indexStatus: indexFlushStaus, - chunkCp: cr.chunk, - }) - checkFlushLock.Unlock() + if dataFlushStatus != nil && indexFlushStaus != nil { + if dataFlushStatus.Flushed() && indexFlushStaus.Flushed() { + saveCheckpoint(rc, tr, engineID, cr.chunk) + } else { + checkFlushLock.Lock() + flushPendingChunks = append(flushPendingChunks, chunkFlushStatus{ + dataStatus: dataFlushStatus, + indexStatus: indexFlushStaus, + chunkCp: cr.chunk, + }) + checkFlushLock.Unlock() + } } } else { metric.ChunkCounter.WithLabelValues(metric.ChunkStateFailed).Add(remainChunkCnt)