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

tidb-server: return 1 while failing to set cpu affinity #30197

Merged
merged 2 commits into from
Dec 2, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions tidb-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,6 @@ func main() {
syncLog()
}

func exit() {
syncLog()
os.Exit(0)
}

func syncLog() {
if err := log.Sync(); err != nil {
// Don't complain about /dev/stdout as Fsync will return EINVAL.
Expand Down Expand Up @@ -259,15 +254,15 @@ func setCPUAffinity() {
c, err := strconv.Atoi(af)
if err != nil {
fmt.Fprintf(os.Stderr, "wrong affinity cpu config: %s", *affinityCPU)
exit()
os.Exit(1)
Copy link
Contributor

Choose a reason for hiding this comment

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

This change removes the syncLog() call, is that intended?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes. I think no need to syncLog here. If it's necessary, many other places need too.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1, sync on stdout/stderr seems be useless uber-go/zap#370 (comment), maybe we can delete them(both in linux and newest macos)

}
cpu = append(cpu, c)
}
}
err := linux.SetAffinity(cpu)
if err != nil {
fmt.Fprintf(os.Stderr, "set cpu affinity failure: %v", err)
exit()
os.Exit(1)
}
runtime.GOMAXPROCS(len(cpu))
metrics.MaxProcs.Set(float64(runtime.GOMAXPROCS(0)))
Expand Down