Skip to content

Commit

Permalink
fix merge bug
Browse files Browse the repository at this point in the history
  • Loading branch information
roseduan committed Aug 18, 2023
1 parent f99e0fe commit 7f5af0f
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7f5af0f

Please sign in to comment.