diff --git a/lib/mergeset/table.go b/lib/mergeset/table.go index 973ca3665..8eddea043 100644 --- a/lib/mergeset/table.go +++ b/lib/mergeset/table.go @@ -911,7 +911,10 @@ var mergeWorkersCount = func() int { }() func openParts(path string) ([]*partWrapper, error) { - // Verify that the directory for the parts exists. + // The path can be missing after restoring from backup, so create it if needed. + if err := fs.MkdirAllIfNotExist(path); err != nil { + return nil, err + } d, err := os.Open(path) if err != nil { return nil, fmt.Errorf("cannot open difrectory: %s", err) diff --git a/lib/storage/partition.go b/lib/storage/partition.go index 50cae5d64..9b3d9a73d 100644 --- a/lib/storage/partition.go +++ b/lib/storage/partition.go @@ -1253,7 +1253,10 @@ func appendPartsToMerge(dst, src []*partWrapper, maxPartsToMerge int, maxRows ui } func openParts(pathPrefix1, pathPrefix2, path string) ([]*partWrapper, error) { - // Verify that the directory for the parts exists. + // The path can be missing after restoring from backup, so create it if needed. + if err := fs.MkdirAllIfNotExist(path); err != nil { + return nil, err + } d, err := os.Open(path) if err != nil { return nil, fmt.Errorf("cannot open directory %q: %s", path, err)