01915a725e
File watches have been a source of complexity and unreliability in the LogFile follow implementation, especially when combined with file rotation. File change events can be unreliably delivered, especially on Windows, and the polling fallback adds latency. Following across rotations has never worked reliably on Windows. Without synchronization between the log writer and readers, race conditions abound: readers can read from the file while a log entry is only partially written, leading to decode errors and necessitating retries. In addition to the complexities stemming from file watches, the LogFile follow implementation had complexity from needing to handle file truncations, and (due to a now-fixed bug in the polling file watcher implementation) evictions to unlock the log file so it could be rotated. Log files are now always rotated, never truncated, so these situations no longer need to be handled by the follow code. Rewrite the LogFile follow implementation in terms of waiting until LogFile notifies it that a new message has been written to the log file. The LogFile informs the follower of the file offset of the last complete write so that the follower knows not to read past that, preventing it from attempting to decode partial messages and making retries unnecessary. Synchronization between LogFile and its followers is used at critical points to prevent missed notifications of writes and races between file rotations and the follower opening files for read. Signed-off-by: Cory Snider <csnider@mirantis.com> |
||
---|---|---|
.. | ||
awslogs | ||
etwlogs | ||
fluentd | ||
gcplogs | ||
gelf | ||
journald | ||
jsonfilelog | ||
local | ||
logentries | ||
loggertest | ||
loggerutils | ||
splunk | ||
syslog | ||
templates | ||
adapter.go | ||
adapter_test.go | ||
copier.go | ||
copier_test.go | ||
factory.go | ||
log_cache_opts.go | ||
logger.go | ||
logger_error.go | ||
logger_test.go | ||
loginfo.go | ||
metrics.go | ||
plugin.go | ||
plugin_unix.go | ||
plugin_unsupported.go | ||
proxy.go | ||
ring.go | ||
ring_test.go |