Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deleting/moving rotated files while the process is running leads to panic #17

Open
mbiggio opened this issue May 13, 2022 · 3 comments · May be fixed by #18
Open

Deleting/moving rotated files while the process is running leads to panic #17

mbiggio opened this issue May 13, 2022 · 3 comments · May be fixed by #18
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@mbiggio
Copy link

mbiggio commented May 13, 2022

I noticed that FileRotate panics if the rotated files are deleted or moved away from the log folder while the application logging through FileRotate is still running.

More precisely, the crash is caused by this assert, in which the code is checking that the file to be renamed in a rotation still exists.

I think the reason for that assert is that FileRotate makes a snapshot of the currently rotated files in the log folder when the scan_suffixes method is called in the constructor, and then assumes that the rotated files will not be moved/deleted by an external process.

Do you think it might be possible to lighen this assumption and be more robust to this usecase?
Thanks for your input on this 🙂

@Ploppz
Copy link
Collaborator

Ploppz commented May 13, 2022

Yeah, that should be made more robust. I guess instead of the assert, we should just call scan_suffixes again if those assumptions are not true (and recurse? or a while loop or something).
I'll get to this next week probably, unless there be a PR before that time ;)

@Ploppz Ploppz added the enhancement New feature or request label May 16, 2022
@Ploppz
Copy link
Collaborator

Ploppz commented May 16, 2022

I started work on this feature

Ploppz added a commit to Ploppz/file-rotate that referenced this issue May 17, 2022
@Ploppz Ploppz added the help wanted Extra attention is needed label Jul 29, 2022
@Ploppz
Copy link
Collaborator

Ploppz commented Jul 29, 2022

Current blocker is concern about race conditions in the comments of my PR.
I wonder if we should use lock files or something, or if we can solve it in another way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
2 participants