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

[jobreceiver] IO issues with logs entires #1309

Open
c-kruse opened this issue Oct 27, 2023 · 1 comment
Open

[jobreceiver] IO issues with logs entires #1309

c-kruse opened this issue Oct 27, 2023 · 1 comment

Comments

@c-kruse
Copy link
Contributor

c-kruse commented Oct 27, 2023

Ran into this a bit in development and now in testing.

We are using go's https://pkg.go.dev/os/exec#Cmd.StdoutPipe, which creates an os.Pipe. On linux that corresponds to a named pipe, which can be especially sensitive to read latency and errors on read after all of the writer fds are closed even when the small read buffer is not empty (resulting in dropped data.) When sensu runs a command it sets exec.Cmd.Stdout to a buffer, and the exec package behind the scenes creates an os.Pipe and starts a goroutine that aggressively reads that pipe into the buffer.

To avoid problems we should add a similar buffer somewhere. The event output handler effectively replicates that buffer here, but the log entries handler currently tries to process records in the read loop. I hope some form of buffer may make this "good enough", but but because of the flawed nature of this form of IPC we can't really apply effective backpressure like we're accustomed to. I suspect this issue exists in the installed collector script sources as well, and just gets papered over with scala the libraries.

@c-kruse
Copy link
Contributor Author

c-kruse commented Oct 27, 2023

Side note: I have my doubts around the suitability of os pipes, but they might not be the root of the problem.
from Cmd.StdoutPipe:

Wait will close the pipe after seeing the command exit, so most callers need not close the pipe themselves. It is thus incorrect to call Wait before all reads from the pipe have completed.

May have just goofed on this and need to reorganize how the command package works to accommodate this.

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