Skip to content

Commit f99e0fe

Browse files
authored
force replace source files (#259)
1 parent 5f3ce73 commit f99e0fe

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

merge.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ func loadMergeFiles(dirPath string) error {
286286
_ = os.RemoveAll(mergeDirPath)
287287
}()
288288

289-
copyFile := func(suffix string, fileId uint32) {
289+
copyFile := func(suffix string, fileId uint32, force bool) {
290290
srcFile := wal.SegmentFileName(mergeDirPath, suffix, fileId)
291291
stat, err := os.Stat(srcFile)
292292
if os.IsNotExist(err) {
@@ -295,7 +295,7 @@ func loadMergeFiles(dirPath string) error {
295295
if err != nil {
296296
panic(fmt.Sprintf("loadMergeFiles: failed to get src file stat %v", err))
297297
}
298-
if stat.Size() == 0 {
298+
if !force && stat.Size() == 0 {
299299
return
300300
}
301301
destFile := wal.SegmentFileName(dirPath, suffix, fileId)
@@ -322,14 +322,14 @@ func loadMergeFiles(dirPath string) error {
322322
return err
323323
}
324324
// move the merge data file to the original data directory
325-
copyFile(dataFileNameSuffix, fileId)
325+
copyFile(dataFileNameSuffix, fileId, false)
326326
}
327327

328328
// copy MERGEFINISHED and HINT files to the original data directory
329329
// there is only one merge finished file, so the file id is always 1,
330330
// the same as the hint file.
331-
copyFile(mergeFinNameSuffix, 1)
332-
copyFile(hintFileNameSuffix, 1)
331+
copyFile(mergeFinNameSuffix, 1, true)
332+
copyFile(hintFileNameSuffix, 1, true)
333333

334334
return nil
335335
}

0 commit comments

Comments
 (0)