fix: Detect appends to files kept open by their writer on Windows - #8
Open
StephKll3c wants to merge 1 commit into
Open
fix: Detect appends to files kept open by their writer on Windows#8StephKll3c wants to merge 1 commit into
StephKll3c wants to merge 1 commit into
Conversation
StephKll3c
force-pushed
the
sc-polling-stat-by-handle
branch
from
July 31, 2026 16:38
18b33f6 to
ca377ca
Compare
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.
On Windows, the polling watcher relied on os.Stat, which reads the directory entry. NTFS does not refresh that entry while another process keeps the file open for writing, which is exactly what SQL Server does with its ERRORLOG. The watcher never saw the file grow, so the tail silently stopped after the initial read (see SekoiaLab/platform#89869, and most likely SekoiaLab/platform#83229 as well, since the fsnotify bump never touched the polling path). The polling loop now stats the file through a handle on Windows, which always returns fresh metadata.
While in there, the polling loop no longer calls util.Fatal on an unexpected stat error, which was killing the whole agent process with os.Exit(1) from a background goroutine. Transient stat errors are now tolerated for a few seconds, then the file is reported as deleted so the tail reopens it instead of dying.