net/http: Client errors caused by Server.Shutdown should be always retryable #65802
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
Go version
go version go1.21.3 linux/amd64
Output of
go env
in your module/workspace:What did you do?
I write a demo to simulate http shutdown.
The demo start a http server and
N
goroutine to send http POST requests. Server and client each has a cache data, akaserverData
andclientData
.N
goroutines are indexed by id, and eagerly send Post request to server with id carried by body. Once HTTP server receives a request, it increases the correspondingserverData
and sends httpOK response. Client goroutine quits for error or increasesclientData
by one.At the end of program,
Server.Shutdown
is called. Wait all client goroutine exit. Check whetherserverData
andclientData
is equal.If
net/http.Server.Shutdown
is perfect graceful, the following situation should not happen.Any client error caused by shutdown should be retryable. This is more friendly for client other than undefined server behavior.
An apparently fix would be checking
Server.shuttingDown
afterreadRequest
but beforeServeHTTP
.What did you see happen?
build and run the demo, I get the following output:
What did you expect to see?
If http.Server.Shutdown is perfect graceful, there should be no logs like
data at index 99 mismatch, client 6044, server 6045
.The text was updated successfully, but these errors were encountered: