-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Add Flush Interval to default Buffered Logger #33009
base: master
Are you sure you want to change the base?
Conversation
Assigning reviewers. If you would like to opt out of this review, comment R: @shunping for label python. Available commands:
The PR bot will only process comments in the main thread (not review comments). |
sdks/python/container/boot.go
Outdated
@@ -278,7 +280,7 @@ func launchSDKProcess() error { | |||
go func(workerId string) { | |||
defer wg.Done() | |||
|
|||
bufLogger := tools.NewBufferedLogger(logger) | |||
bufLogger := tools.NewBufferedLoggerWithFlushInterval(context.Background(), logger, loggerFlushInterval) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about we make flush interval the default behavior, unless disabled, as opposed to having to instantiate a special instance of BufLogger?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having looked at it we do use both instantiation methods in different places. We could clean things up and unify those paths if we really, really felt the need to but in this context that seems unnecessary. This kind of overloaded constructor pattern isn't atypical in Go, and I think the distinct methods provide a pretty clear indication of what you're getting when you use them (buffering vs buffering with a regular flush interval.)
If there was another code change to make it'd probably be to add some sort of flushing behavior every X logging entries stored, but that may be overcomplicating things in the case of dumping long tracebacks for errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My point is less about code style but that we shouldn't be using buffered logger without flushing ever, looks like this is the last place where we do so: https://github.com/search?q=repo%3Aapache%2Fbeam%20NewBufferedLogger&type=code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the code more I'm a little surprised that there isn't any sort of flush mechanism beyond the time. I think we wound up dropping the buffered logging into the worker process startup to catch any early errors and it wound up swallowing too much. 10-15 seconds as a default should be fine then
I may try to come back to the buffered logging at some point when I have more time and try to do some other polishing, I have a few ideas as to why outputs from python segfaults get all screwy now.
LGTM, thank you! Please test the change in Dataflow. Optionally, consider using NewBufferedLogger where the other constructor is used, if it makes sense or keep as is. |
Adds a default flush interval of 15 seconds to the BufferedLogger type to avoid logs being held until the job ends.
Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
addresses #123
), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, commentfixes #<ISSUE NUMBER>
instead.CHANGES.md
with noteworthy changes.See the Contributor Guide for more tips on how to make review process smoother.
To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md
GitHub Actions Tests Status (on master branch)
See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.