You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working on a tool which sometimes talks to PostgreSQL. While developing I build the tool with go 1.21rc3 and with the flag -race enabled. I noticed something odd: everytime the tool uses networking it would take approximately a second to exit (after the main function has returned).
After some testing I found out the following code exhibits the same problem:
If you build this code with Go 1.21rc3 and with -race you should notice a significant delay before the program exits, after the "elapsed" log has been printed.
Building with Go 1.21rc3 without-race doesn't have the problem
Building with Go 1.20, with or without -race doesn't have the problem
This is true on macOS and on Linux
What did you expect to see?
I expected the program to exit immediately after the main function has returned, as it does when built with Go 1.20.
What did you see instead?
After the main function has returned the program takes ~1s to exit
The text was updated successfully, but these errors were encountered:
The GORACE environment variable sets race detector options. The format is:
GORACE="option1=val1 option2=val2"
The options are:
...
atexit_sleep_ms (default 1000): Amount of milliseconds to sleep in the main goroutine before exiting.
If you try to run your example after setting GORACE properly there is no sleep:
$ unset GORACE
$ go build -race main.go
$ time ./main
2023/07/30 13:51:25 elapsed: 569.891334ms
./main 0.11s user 0.00s system 6% cpu 1.576 total
$ export GORACE=atexit_sleep_ms=0
$ time ./main
2023/07/30 13:51:46 elapsed: 488.13579ms
./main 0.08s user 0.03s system 22% cpu 0.494 total
What version of Go are you using (
go version
)?on macOS:
go version go1.21rc3 darwin/arm64
on Linux:
go version go1.21rc3 linux/amd64
Does this issue reproduce with the latest release?
No
What operating system and processor architecture are you using (
go env
)?on macOS:
go env
Outputon Linux:
go env
OutputWhat did you do?
I'm working on a tool which sometimes talks to PostgreSQL. While developing I build the tool with go 1.21rc3 and with the flag
-race
enabled. I noticed something odd: everytime the tool uses networking it would take approximately a second to exit (after themain
function has returned).After some testing I found out the following code exhibits the same problem:
This is what I found:
-race
you should notice a significant delay before the program exits, after the "elapsed" log has been printed.-race
doesn't have the problem-race
doesn't have the problemWhat did you expect to see?
I expected the program to exit immediately after the main function has returned, as it does when built with Go 1.20.
What did you see instead?
After the main function has returned the program takes ~1s to exit
The text was updated successfully, but these errors were encountered: