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

Slow mocks shutdown in Go 1.15 #57

Closed
fetinin opened this issue Sep 2, 2020 · 3 comments · Fixed by #59
Closed

Slow mocks shutdown in Go 1.15 #57

fetinin opened this issue Sep 2, 2020 · 3 comments · Fixed by #59
Labels
enhancement New feature or request go1.15

Comments

@fetinin
Copy link
Contributor

fetinin commented Sep 2, 2020

In Go 1.15 behavior of http.Server.Shutdown changed and now server waits for all listeners to disconnect.

// go/1.15/libexec/src/net/http/server.go:2699
...
ticker := time.NewTicker(shutdownPollInterval) // 500 ms
defer ticker.Stop()
for {
	if srv.closeIdleConns() && srv.numListeners() == 0 { // for some reason this is always false first time
		return lnerr
	}
	select {
	case <-ctx.Done():
		return ctx.Err()
	case <-ticker.C:  // we always wait here half a second
	}
...

For some reason, on mock shutdown we always still have some active connections and shutdown takes about 500ms. And since we shutdown all mocks synchronously with a lot of mocks we wait for tests to finish for up to 18 seconds.

Does anyone else have this issue?

As a solution we can close each mock server in a separate goroutine, that should reduce wait time for us from 18s to 500ms.

@fetinin fetinin added enhancement New feature or request go1.15 labels Sep 2, 2020
@luza
Copy link
Contributor

luza commented Sep 2, 2020

Suggested solution looks more like a work around. I'd better find out why it can't be shut down immediately as I don't see any reason to wait even 500 ms.

@irr123
Copy link
Contributor

irr123 commented Sep 2, 2020

Look at this PR #58

@fetinin fetinin linked a pull request Sep 2, 2020 that will close this issue
@fetinin fetinin linked a pull request Sep 3, 2020 that will close this issue
@fetinin
Copy link
Contributor Author

fetinin commented Sep 3, 2020

Fixed in #59

@fetinin fetinin closed this as completed Sep 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request go1.15
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants