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

Race condition when logfile is rotated while pygtail is running #71

Open
pajowu opened this issue Feb 8, 2024 · 0 comments
Open

Race condition when logfile is rotated while pygtail is running #71

pajowu opened this issue Feb 8, 2024 · 0 comments

Comments

@pajowu
Copy link
Contributor

pajowu commented Feb 8, 2024

There is at least one race condition when creating a pygtail instance at the same time a logfile is rotated, which can lead to impossible offset files being created. A test-case for this can be found in this commit: 98d3d50

This is caused by __init__ determining the name of the logfile referenced by offset_file_inode, but the file only being opened once the first line is read. If the file was rotated in between, _filehandle will open the newer logfile, but try to seek to the old offset, which in most cases is after the end of the file, so the read will fail. However when writing the offset, tell() is used, which will return the offset that was seeked to, not the length of the new file -> We end up with the inode of the new file, but the old offset being written to the offset file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant