lib/{fs,mergeset,storage}: skip .must-remove. dirs when creating snapshot (#3858) (#3867)

This commit is contained in:
Zakhar Bessarab 2023-02-25 00:38:42 +04:00 committed by Aliaksandr Valialkin
parent 1026e25f33
commit c9547f4fba
No known key found for this signature in database
GPG key ID: A72BEC6CD3D0DED1
3 changed files with 7 additions and 3 deletions

View file

@ -262,7 +262,7 @@ func MustRemoveTemporaryDirs(dir string) {
continue continue
} }
dirName := fi.Name() dirName := fi.Name()
if strings.Contains(dirName, ".must-remove.") { if IsScheduledForRemoval(dirName) {
fullPath := dir + "/" + dirName fullPath := dir + "/" + dirName
MustRemoveAll(fullPath) MustRemoveAll(fullPath)
} }
@ -467,3 +467,7 @@ func isHTTPURL(targetURL string) bool {
return err == nil && (parsed.Scheme == "http" || parsed.Scheme == "https") && parsed.Host != "" return err == nil && (parsed.Scheme == "http" || parsed.Scheme == "https") && parsed.Host != ""
} }
func IsScheduledForRemoval(name string) bool {
return strings.Contains(name, ".must-remove.")
}

View file

@ -1835,5 +1835,5 @@ func removeParts(pws []*partWrapper, partsToRemove map[*partWrapper]bool) ([]*pa
func isSpecialDir(name string) bool { func isSpecialDir(name string) bool {
// Snapshots and cache dirs aren't used anymore. // Snapshots and cache dirs aren't used anymore.
// Keep them here for backwards compatibility. // Keep them here for backwards compatibility.
return name == "tmp" || name == "txn" || name == "snapshots" || name == "cache" return name == "tmp" || name == "txn" || name == "snapshots" || name == "cache" || fs.IsScheduledForRemoval(name)
} }

View file

@ -2022,7 +2022,7 @@ func (pt *partition) createSnapshot(srcDir, dstDir string) error {
// Skip non-directories. // Skip non-directories.
continue continue
} }
if fn == "tmp" || fn == "txn" { if fn == "tmp" || fn == "txn" || fs.IsScheduledForRemoval(fn) {
// Skip special dirs. // Skip special dirs.
continue continue
} }