mirror of
https://github.com/facebook/sapling.git
synced 2024-10-09 16:31:02 +03:00
rotatelog: add fix cleaning up partially cleaned up logs
Summary: Our log deletion is a two step process. First it deletes the meta file, then it deletes the log. There was a bug where if the meta file deletion succeeded but the log deletion failed (often because Eden has the log open) then future attempts to delete the log will fail because it fails to delete the meta file. Reviewed By: quark-zju Differential Revision: D29035913 fbshipit-source-id: 33ab9a4e46b285819c4bf14031426983d2b4342f
This commit is contained in:
parent
60001b5161
commit
63884d65c1
@ -571,8 +571,21 @@ impl RotateLog {
|
||||
// Newly opened or flushed RotateLog will unmap files.
|
||||
// New rotation would trigger remove_dir_all to try
|
||||
// remove old logs again.
|
||||
let res = fs::remove_file(entry.path().join(log::META_FILE))
|
||||
.and_then(|_| fs::remove_dir_all(entry.path()));
|
||||
match fs::remove_file(entry.path().join(log::META_FILE)) {
|
||||
Ok(()) => {}
|
||||
Err(e) if e.kind() == io::ErrorKind::NotFound => {
|
||||
// Meta file is already deleted.
|
||||
}
|
||||
Err(e) => {
|
||||
// Don't delete the log if we were unable to delete the
|
||||
// meta file.
|
||||
debug!("Error removing rotate log meta: {:?}", name);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Delete the rest of the directory.
|
||||
let res = fs::remove_dir_all(entry.path());
|
||||
match res {
|
||||
Ok(_) => debug!("Removed rotate log: {:?}", name),
|
||||
Err(err) => {
|
||||
|
Loading…
Reference in New Issue
Block a user