Skip to content

Commit 0a53ed1

Browse files
authored
Reject requests after getting close session request. (#12618)
* Kqp request can came just after close session request. In this case there is a gap when session actor is already DEAD but kqp proxy stil has a record in the local sessions. Changelog category: * Bugfix
1 parent 9d8fcc7 commit 0a53ed1

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

ydb/core/kqp/proxy_service/kqp_proxy_service.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,11 @@ class TKqpProxyService : public TActorBootstrapped<TKqpProxyService> {
723723
}
724724

725725
if (sessionInfo) {
726+
if (sessionInfo->Closing) {
727+
TString error = TStringBuilder() << "Session is closing";
728+
ReplyProcessError(Ydb::StatusIds::BAD_SESSION, error, requestId);
729+
return;
730+
}
726731
LocalSessions->AttachQueryText(sessionInfo, ev->Get()->GetQuery());
727732
}
728733

@@ -784,6 +789,7 @@ class TKqpProxyService : public TActorBootstrapped<TKqpProxyService> {
784789
}
785790

786791
if (sessionInfo) {
792+
LocalSessions->SetSessionClosing(sessionInfo);
787793
Send(sessionInfo->WorkerId, ev->Release().Release());
788794
} else {
789795
if (!sessionId.empty()) {

ydb/core/kqp/proxy_service/kqp_proxy_service_impl.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ struct TKqpSessionInfo {
9898
TActorId AttachedRpcId;
9999
bool PgWire;
100100
TString QueryText;
101-
bool Ready = true;
102101
TString ClientApplicationName;
103102
TString ClientSID;
104103
TString ClientHost;
@@ -111,6 +110,7 @@ struct TKqpSessionInfo {
111110
TInstant QueryStartAt;
112111

113112
ESessionState State = ESessionState::IDLE;
113+
bool Closing = false;
114114

115115
struct TFieldsMap {
116116
ui64 bitmap = 0;
@@ -246,6 +246,11 @@ class TLocalSessionsRegistry {
246246
return candidate;
247247
}
248248

249+
void SetSessionClosing(const TKqpSessionInfo* sessionInfo) {
250+
TKqpSessionInfo* info = const_cast<TKqpSessionInfo*>(sessionInfo);
251+
info->Closing = true;
252+
}
253+
249254
void StartIdleCheck(const TKqpSessionInfo* sessionInfo, const TDuration idleDuration) {
250255
if (!sessionInfo) {
251256
return;

0 commit comments

Comments
 (0)