Skip to content

Commit de10ae4

Browse files
authored
Merge pull request #491 from ydb-platform/ResourceExhausted-isn't-pessimize-the-node
feat: ResourceExhausted isn't pessimize the node
2 parents 7ef52fb + ee9f83f commit de10ae4

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

core/src/main/java/tech/ydb/core/impl/YdbTransportImpl.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import java.net.URISyntaxException;
55
import java.time.Duration;
66
import java.time.Instant;
7-
import java.util.Arrays;
87
import java.util.Collections;
98
import java.util.List;
109
import java.util.concurrent.CompletableFuture;
@@ -54,7 +53,8 @@ public YdbTransportImpl(GrpcTransportBuilder builder) {
5453

5554
this.channelFactory = builder.getManagedChannelFactory();
5655
this.scheduler = builder.getSchedulerFactory().get();
57-
this.callOptions = new AuthCallOptions(scheduler, Arrays.asList(discoveryEndpoint), channelFactory, builder);
56+
this.callOptions = new AuthCallOptions(scheduler, Collections.singletonList(discoveryEndpoint),
57+
channelFactory, builder);
5858
this.channelPool = new GrpcChannelPool(channelFactory, scheduler);
5959
this.endpointPool = new EndpointPool(balancingSettings);
6060
this.discovery = new YdbDiscovery(new DiscoveryHandler(), scheduler, database, discoveryTimeout);
@@ -171,7 +171,10 @@ protected GrpcChannel getChannel(GrpcRequestSettings settings) {
171171
@Override
172172
protected void updateChannelStatus(GrpcChannel channel, io.grpc.Status status) {
173173
// Usally CANCELLED is received when ClientCall is canceled on client side
174-
if (!status.isOk() && status.getCode() != io.grpc.Status.Code.CANCELLED) {
174+
if (!status.isOk() && status.getCode() != io.grpc.Status.Code.CANCELLED &&
175+
status.getCode() != io.grpc.Status.Code.DEADLINE_EXCEEDED &&
176+
status.getCode() != io.grpc.Status.Code.RESOURCE_EXHAUSTED
177+
) {
175178
endpointPool.pessimizeEndpoint(channel.getEndpoint());
176179
}
177180
}

core/src/test/java/tech/ydb/core/impl/pool/EndpointPoolTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ public class EndpointPoolTest {
3737

3838
@Before
3939
public void setUp() throws IOException {
40+
Mockito.when(socketFactory.createSocket()).thenReturn(socket);
41+
Mockito.doNothing().when(socket).connect(Mockito.any(SocketAddress.class));
4042
mocks = MockitoAnnotations.openMocks(this);
4143
threadLocalStaticMock.when(ThreadLocalRandom::current).thenReturn(random);
4244
socketFactoryStaticMock.when(SocketFactory::getDefault).thenReturn(socketFactory);
43-
Mockito.when(socketFactory.createSocket()).thenReturn(socket);
44-
Mockito.doNothing().when(socket).connect(Mockito.any(SocketAddress.class));
4545
}
4646

4747
@After

0 commit comments

Comments
 (0)