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

Add Flush Interval to default Buffered Logger #33009

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jrmccluskey
Copy link
Contributor

@jrmccluskey jrmccluskey commented Nov 4, 2024

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:

  • Mention the appropriate issue in your description (for example: 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, comment fixes #<ISSUE NUMBER> instead.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

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)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.

Copy link
Contributor

github-actions bot commented Nov 4, 2024

Assigning reviewers. If you would like to opt out of this review, comment assign to next reviewer:

R: @shunping for label python.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

@@ -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)
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor Author

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.

@github-actions github-actions bot added go and removed go labels Nov 4, 2024
@github-actions github-actions bot added go and removed python labels Nov 4, 2024
@jrmccluskey jrmccluskey changed the title Add Flush Interval to default Buffered Logger in Python boot.go Add Flush Interval to default Buffered Logger Nov 4, 2024
@github-actions github-actions bot added python and removed go labels Nov 4, 2024
@tvalentyn
Copy link
Contributor

tvalentyn commented Nov 5, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants