Backup aborts when a file disappears during archiving (ENOENT from os.Lstat in writeTarball)
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 20/100
Hướng nghiên cứu
Start with cmd/backup/archive.go around writeTarball and inspect how compress() handles its errors; also review cmd/backup/create_archive.go to understand failures during the initial walk. Check the linked pull request #909 for work already underway. Done means missing files during the walk or archive write no longer abort the backup, with tests covering the race and the resulting archive.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
What happens
If a file is removed or replaced while the archive is being written, the backup aborts completely and the resulting archive is discarded.
This is easy to hit when backing up live application data: a database sidecar file, a session snapshot or a rotating log that changes mid-run is enough to kill the whole backup, after minutes of compression.
Version
- Running: v2.50.1
- Code reviewed in: v2.50.2 (same code path)
Expected behavior
A file that no longer exists at archiving time should be skipped (optionally logged as a warning), and the backup should complete with the files that do exist. One transient file is not a reason to discard the entire archive.
Actual behavior
The first ENOENT from os.Lstat aborts the whole run:
cmd/backup/create_archive.go:60—filepath.WalkDirbuilds the list of paths to archive; any walk error aborts.cmd/backup/archive.go:77—compress()returns on the firstwriteTarballerror.cmd/backup/archive.go:127—writeTarballcallsos.Lstat(path)and returns the error, includingENOENT.
Error shape:
main.compress: error writing <path> to archive:
main.writeTarball: error getting file info for <path>:
lstat <path>: no such file or directory
The only special cases handled today are sockets (skipped) and symlinks (resolved).
Suggested fix
In writeTarball, treat ENOENT (and optionally ESTALE) as skippable:
fileInfo, err := os.Lstat(path)
if err != nil {
if errors.Is(err, os.ErrNotExist) {
// file disappeared between walk and archive; skip it
return nil
}
returnErr = errwrap.Wrap(err, fmt.Sprintf("error getting file info for %s", path))
return
}
The same guard is needed around os.Open(path), since a file can vanish between Lstat and Open. A warning-level log line per skipped file keeps it observable.
If fail-fast should stay the default, an opt-in variable (e.g. BACKUP_SKIP_MISSING_FILES) would also solve it.
Workarounds tried
BACKUP_EXCLUDE_REGEXP— mitigates known paths, but cannot cover files created with unpredictable names at unpredictable times.BACKUP_FROM_SNAPSHOT— deprecated in the current release, and the pre-copy phase walks the tree withlstattoo, so the race remains (it also doubles required disk space).BACKUP_STOP_DURING_BACKUP_LABEL— only covers containers, not host processes writing to mounted directories.- Filesystem snapshots — not available on every host.
Impact
For anyone backing up live application directories, a single transient file can prevent every backup from completing.
- Ngôn ngữ chính
- Go
- Star
- 4.1k
- Fork
- 157
- Merge trung bình
- 4 giờ 35 phút
- Pull request đã merge (30 ngày)
- 15
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của offen/docker-volume-backup
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
offen/docker-volume-backup#910 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Feat: age post quantum supportĐang mởenhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 15/100
offen/docker-volume-backup#879 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Migrate away from `minio-go`Đang mởmaintenance pr welcome
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
offen/docker-volume-backup#869 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation pr welcome
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
offen/docker-volume-backup#796 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
offen/docker-volume-backup#749 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của offen/docker-volume-backup
Issue tương tự
-
area/ui-schema good first issue type/bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 4 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
router-for-me/CLIProxyAPI#8573 ·
Maintainer thường phản hồi trong vòng 9 ngày
-
bug: minute-granularity sync timestamp makes e2e tests asserting "Already in sync" fail sporadicallyĐang mởbug package:cmd priority:3-low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
docToolchain/Bausteinsicht#761 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Flaky test: kb TestUnknownLabelValuesAreFoldedNotExported fails when the start epoch contains 799Đang mởarea/knowledge kind/bug priority/p1 status/accepted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
openagentix/openagentix#253 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 76/100
quii/learn-go-with-tests#934 · 1 bình luận ·