Skip to content

Commit 026a020

Browse files
committed
Added removing session from the pool, if client cancelled the stream
1 parent 36ac96c commit 026a020

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

query/src/main/java/tech/ydb/query/impl/SessionImpl.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ abstract class SessionImpl implements QuerySession {
5858
YdbQuery.DeleteSessionResponse::getStatus, YdbQuery.DeleteSessionResponse::getIssuesList
5959
);
6060

61+
private static final Status CANCELLED = Status.of(
62+
StatusCode.CLIENT_CANCELLED,
63+
Issue.of("Stream was cancelled by client, session will be removed", Issue.Severity.WARNING)
64+
);
65+
6166
private final QueryServiceRpc rpc;
6267
private final String sessionId;
6368
private final long nodeID;
@@ -313,6 +318,7 @@ public CompletableFuture<Result<QueryInfo>> execute(PartsHandler handler) {
313318

314319
@Override
315320
public void cancel() {
321+
updateSessionState(CANCELLED);
316322
grpcStream.cancel();
317323
}
318324
}

query/src/main/java/tech/ydb/query/impl/SessionPool.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ public void updateSessionState(Status status) {
175175
status.getCode() == StatusCode.INTERNAL_ERROR ||
176176
status.getCode() == StatusCode.CLIENT_DEADLINE_EXCEEDED ||
177177
status.getCode() == StatusCode.CLIENT_DEADLINE_EXPIRED ||
178+
status.getCode() == StatusCode.CLIENT_CANCELLED ||
178179
status.getCode() == StatusCode.TRANSPORT_UNAVAILABLE;
179180
if (isStatusBroken) {
180181
logger.warn("QuerySession[{}] broken with status {}", getId(), status);

0 commit comments

Comments
 (0)