To avoid connection leak, call `close()` immediately after connection
is established. In regular tree pool, unhealthy connections are handled
by background goroutine which calls `redialIfNecessary()` to reestablish
connection. Here it is not viable so connection must be close.
Signed-off-by: Alex Vanin <a.vanin@yadro.com>
Two concurrent 'deleteClientFromMap' calls for
the same client may produce panic and deadlock.
First goroutine acquires lock, removes element
from the map, releases lock.
Second goroutine acquires lock, and throws panic
while trying to call 'close()' on empty struct.
Lock is never released and it causes deadlock for
other goroutines.
Signed-off-by: Alex Vanin <a.vanin@yadro.com>
New version of tree/pool selects tree service connection to make request based on the current net map and container placement policy
Signed-off-by: Marina Biryukova <m.biryukova@yadro.com>
Since api was moved from `TrueCloudLab/frostfs-api-go` to sdk,
moving changes from TrueCloudLab/frostfs-api-go#125 here.
Signed-off-by: Ekaterina Lebedeva <ekaterina.lebedeva@yadro.com>
* `c.conn` may be already invalidated but the rpc client can't detect this.
`NewStream` may hang trying to open a stream with invalidated connection.
Using timer with `dialTimeout` for `NewStream` fixes this problem.
Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
* Sending empty chunks by `writeChunk` should not release new
objects as this doesn't change `payloadSizeLimiter` internal
state.
* This also fixes the bug with patcher when an offset of a patch
equals to `MaxSize` - `payloadSizeLimiter` releases object again
although state is the same. This led to error because EC-encoder
receieved empty payload and couldn't not process it.
Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
Implemented context timeout for all tree service operations except those that return a GRPC stream
Signed-off-by: Nikita Zinkevich <n.zinkevich@yadro.com>
A particular status code does not imply that a connection has not been
established. However, `Dial()` requires user to call `Close()` only if
the error was nil. Thus, it is `Dial()` responsibility to close
everything if it returns an error.
Introduced after the gRPC update in #270 (6009d089fc).
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
After removing `grpc.Dial` from client `DialTimeout` used only if
custom dialer provided. Client uses `BalanceOf` instead of `grpc.Dial`,
so it is required to use `DialTimeout` to not to use RPC timeout.
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>