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

fix: Error on rotated file if new file takes time to appear #22

Merged
merged 5 commits into from
Jun 2, 2021

Conversation

darinspivey
Copy link
Contributor

fix: Error on rotated file if new file takes time to appear

When a file's inode changes, or the stat call throws
causes tail-file to read the remainder of the contents
via a FileHandle. If the file disappears, but takes a bit
to re-appear, _readRemainderFromFileHandle() is
erroneously called twice; once for the ENOENT from the
disappearing file, and once when the new file causes the
inode to change. This commit fixes a bug where the FH is
nullified after the first call, and thus throws on the
subsequent call.

Semver: patch
Fixes: #18


refactor: memory-usage tests should use a temp directory

The test for memory consumption creates a large log file.
Previously, it was creating it in the local test directory
which clutters up the project dir and could potentially
get committed. This change restructures the test to use
a temp directory as given by the OS.

Semver: patch


deps: tap@15.0.9


deps: eslint-config-logdna@5.1.0


deps: eslint@7.27.0

The test for memory consumption creates a large log file.
Previously, it was creating it in the local test directory
which clutters up the project dir and could potentially
get committed. This change restructures the test to use
a temp directory as given by the OS.

Semver: patch
@darinspivey darinspivey requested review from jorgebay and mdeltito June 1, 2021 14:17
@jorgebay
Copy link

jorgebay commented Jun 1, 2021

I'll look at this today.

@darinspivey darinspivey force-pushed the darinspivey/issue18 branch from b6978bb to dc4dd2c Compare June 1, 2021 14:50
Copy link

@jorgebay jorgebay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's looking good, I've added a minor remark below.

I think there's a small race condition on _readRemainderFromFileHandle() that might be more likely to appear now: we are nullifying the file handle field after async reading/closing of the file handle (other events/timers can occur in the meantime). Instead, we could store the reference to the file handle locally, set the property to null and then do the async ops.

@darinspivey darinspivey force-pushed the darinspivey/issue18 branch 6 times, most recently from d0d8cb4 to 652e0bd Compare June 1, 2021 17:44
@darinspivey darinspivey requested a review from jorgebay June 1, 2021 17:46
mdeltito
mdeltito previously approved these changes Jun 1, 2021
When a file's inode changes, or the `stat` call throws
causes tail-file to read the remainder of the contents
via a FileHandle. If the file disappears, but takes a bit
to re-appear, `_readRemainderFromFileHandle()` is
erroneously called twice; once for the `ENOENT` from the
disappearing file, and once when the new file causes the
inode to change. This commit fixes a bug where the FH is
nullified after the first call, and thus throws on the
subsequent call.

Semver: patch
Fixes: #18
@darinspivey darinspivey merged commit 08c8472 into main Jun 2, 2021
@darinspivey darinspivey deleted the darinspivey/issue18 branch June 2, 2021 13:29
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

Successfully merging this pull request may close these issues.

Error on rotated file if new file takes time to appear
3 participants