Cancel age context once RPC ends
Closes #157 (closed).
Closes #146 (closed).
Above issues are happening because connection age context depends on the transport context but not on the RPC context. Hence when RPC ends, the age context is not cancelled. It is cancelled later, when the transport (TCP) connection is closed.
For the kas->Gitaly throttling issue this bug results in Gitaly polling continuing even after agent disconnects. Throttling is happening because an agent would establish a new connection and kas would start one more polling loop, in addition to the one that's already running.
For proxy error issue this bug causes TunnelRegistry
to hold onto connections that have already disconnected as if they are still active. When a tunnel is needed, TunnelRegistry
picks one of such connections, tries to write to it and fails with the transport: the stream is done or WriteHeader was already called
error.