Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #505.
When a log on an NFS/EFS mount is rotated, reads on the open descriptor
return ESTALE. The file stream handles that by reopening, but it reopens
immediately: unlike every other path in the read loop, the ESTALE path
never waits on the waker. On a mount where the reopened file is stale as
well, the stream reopens as fast as the kernel will let it, which burns a
core and fills the log with
until the mount recovers. Every turn of that loop also leaks a wakeup-less
goroutine handoff and bumps log_opens_total.
This change waits for the next wakeup before reopening, so a stale mount
costs one read per poll interval instead of a busy loop.
Two related problems in the same path:
If the reopen itself failed, the stream returned without closing its
lines channel. The Tailer only drops a source when that channel
closes, so the pathname stayed in its map, TailPath kept returning
early with "already got a logstream", and the log was never tailed
again. The stream now closes the channel when it gives up, and the
Tailer picks the file up again on the next pattern poll.
The reopen passed the caller's os.FileInfo down to the new stream, so
the new stream compared the file it was reading against a FileInfo
from a file it had never opened, and spawned another stream at the
first EOF. stream() now stats its own descriptor, and the FileInfo
parameter is gone from stream() and newFileStream().
Tests inject ESTALE through a seam on the file stream's reader, because a
local filesystem won't produce it on demand. They cover both the read rate
across wakeups and the channel close after a failed reopen; both fail
against the current code.
w/ help from Claude