Fix Gitaly hanging after cancelled InfoRefs request
When we have an info ref cache miss and the request context is
cancelled when missFn
is being executed, we could end up in a
situation where the command is blocked trying to write/copy the last bytes of
stdout to a pipe that's not being read from (because this goroutine
has exited at this point after the context was cancelled).
Discarding the remaining bytes doesn't work because all reads from
the TeeReader
are matched with writes to the writer it writes to, in
this case it is a gRPC stream that's closed because the context was
cancelled, so it will err out.
Closing the reading-end of the pipe side fixes this problem and unblocks
the command's Wait()
call.
Fixes #5953 (closed)
Edited by Ahmad Sherif