From 7f5af0f3d8be53926bfab9fc2c5d2bb265cd616f Mon Sep 17 00:00:00 2001 From: roseduan Date: Fri, 18 Aug 2023 13:19:08 +0800 Subject: [PATCH] fix merge bug --- merge.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/merge.go b/merge.go index 2f09e999..fc94a299 100644 --- a/merge.go +++ b/merge.go @@ -311,15 +311,20 @@ func loadMergeFiles(dirPath string) error { // should be moved to the original data directory, and the original data files should be deleted. for fileId := uint32(1); fileId <= mergeFinSegmentId; fileId++ { destFile := wal.SegmentFileName(dirPath, dataFileNameSuffix, fileId) + // will have bug here if continue, check it later.todo + // If we call Merge multiple times, some segment files will be deleted earlier, so just skip them. - if _, err = os.Stat(destFile); os.IsNotExist(err) { - continue - } else if err != nil { - return err - } + // if _, err = os.Stat(destFile); os.IsNotExist(err) { + // continue + // } else if err != nil { + // return err + // } + // remove the original data file - if err = os.Remove(destFile); err != nil { - return err + if _, err = os.Stat(destFile); err == nil { + if err = os.Remove(destFile); err != nil { + return err + } } // move the merge data file to the original data directory copyFile(dataFileNameSuffix, fileId, false)