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

maxprocs: Print newline after log #583

Merged
merged 2 commits into from
Nov 4, 2022
Merged

maxprocs: Print newline after log #583

merged 2 commits into from
Nov 4, 2022

Conversation

mterwill
Copy link
Member

@mterwill mterwill commented Nov 4, 2022

💸 TL;DR

Since we're not using a real logger here (artifact of previous implementation, I think because logging isn't initialized when this is called – but if that's not the case we can update to use zap) we weren't logging a newline. This was not caught by tests because the maxprocs library doesn't bake in any testing affordances so we had to stub it out.

📜 Details

Before:

maxprocs: Updating GOMAXPROCS=8: determined from CPU quotapanic: runtime error: invalid memory address or nil pointer dereference

After:

maxprocs: Updating GOMAXPROCS=8: determined from CPU quota
panic: runtime error: invalid memory address or nil pointer dereference

🧪 Testing Steps / Validation

Will test in a sample service.

✅ Checks

  • CI tests (if present) are passing
  • Adheres to code style for repo
  • Contributor License Agreement (CLA) completed if not a Reddit employee

@mterwill mterwill requested a review from fishy November 4, 2022 18:12
@mterwill mterwill requested a review from a team as a code owner November 4, 2022 18:12
@mterwill mterwill requested review from pacejackson and ghirsch-reddit and removed request for a team November 4, 2022 18:12
@@ -74,7 +74,7 @@ var (
ubermaxprocs.Set(
ubermaxprocs.Min(2),
ubermaxprocs.Logger(func(s string, i ...interface{}) {
fmt.Fprintf(os.Stderr, s, i...) // contains context
fmt.Fprintf(os.Stderr, s+"\n", i...) // contains context
Copy link
Member Author

@mterwill mterwill Nov 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another concern of not using a real logging library is that this could get interleaved, but (a) this happens early in setup, so there shouldn't be any other goroutines running and (b) these log messages are small, should always be smaller than PIPE_BUF, so the OS guarantees they'll be atomic. (er - I guess that's for different processes, not sure what Go does but seems fine https://go.dev/play/p/WIyt9Npaii9)

Copy link
Member

@fishy fishy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think because logging isn't initialized when this is called

yes that's the reason.

runtimebp/internal/maxprocs/maxprocs.go Outdated Show resolved Hide resolved
@mterwill mterwill merged commit c06ebf3 into master Nov 4, 2022
@fishy fishy deleted the maxprocs-newline branch November 4, 2022 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants