Skip to content

Report nodeId with create session response. #562

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions ydb/core/grpc_services/rpc_common/rpc_common_kqp_session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class TCreateSessionRPC : public TActorBootstrapped<TCreateSessionRPC> {
// We already lost the client, so the client should not see this status
Reply(Ydb::StatusIds::INTERNAL_ERROR);
} else {
SendSessionResult(kqpResponse.GetSessionId());
SendSessionResult(kqpResponse);
PassAway();
return;
}
Expand All @@ -134,7 +134,7 @@ class TCreateSessionRPC : public TActorBootstrapped<TCreateSessionRPC> {
}

private:
virtual void SendSessionResult(const TString& id) = 0;
virtual void SendSessionResult(const NKikimrKqp::TCreateSessionResponse& kqpResponse) = 0;

template<typename TResp>
void ReplyResponseError(const TResp& kqpResponse) {
Expand Down Expand Up @@ -171,9 +171,9 @@ class TCreateSessionTableService : public TCreateSessionRPC {
}

private:
void SendSessionResult(const TString& id) override {
void SendSessionResult(const NKikimrKqp::TCreateSessionResponse& kqpResponse) override {
Ydb::Table::CreateSessionResult result;
result.set_session_id(id);
result.set_session_id(kqpResponse.GetSessionId());
static_cast<TCtx*>(Request.get())->SendResult(result, Ydb::StatusIds::SUCCESS);
};
};
Expand All @@ -186,11 +186,15 @@ class TCreateSessionQueryService : public TCreateSessionRPC {
}

private:
void SendSessionResult(const TString& id) override {
void SendSessionResult(const NKikimrKqp::TCreateSessionResponse& kqpResponse) override {
using TRes = Ydb::Query::CreateSessionResponse;
auto res = google::protobuf::Arena::CreateMessage<TRes>(Request->GetArena());;
res->set_status(Ydb::StatusIds::SUCCESS);
res->set_session_id(id);
res->set_session_id(kqpResponse.GetSessionId());

if (kqpResponse.HasNodeId())
res->set_node_id(kqpResponse.GetNodeId());

Request->Reply(res, Ydb::StatusIds::SUCCESS);
};
};
Expand Down
1 change: 1 addition & 0 deletions ydb/core/kqp/proxy_service/kqp_proxy_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ class TKqpProxyService : public TActorBootstrapped<TKqpProxyService> {
{
auto& response = *responseEv->Record.MutableResponse();
response.SetSessionId(result.Value->SessionId);
response.SetNodeId(SelfId().NodeId());
dbCounters = result.Value->DbCounters;
} else {
dbCounters = Counters->GetDbCounters(request.GetDatabase());
Expand Down
1 change: 1 addition & 0 deletions ydb/core/protos/kqp.proto
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ message TEvCreateSessionRequest {

message TCreateSessionResponse {
optional bytes SessionId = 1;
optional int64 NodeId = 2;
}

message TEvCreateSessionResponse {
Expand Down
1 change: 1 addition & 0 deletions ydb/public/lib/ut_helpers/ut_helpers_query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ TString CreateQuerySession(const TGRpcClientConfig& clientConfig) {
UNIT_ASSERT_C(grpcStatus.GRpcStatusCode == 0, grpcStatus.Msg + " " + grpcStatus.Details);
UNIT_ASSERT_VALUES_EQUAL(response.status(), Ydb::StatusIds::SUCCESS);
UNIT_ASSERT(response.session_id() != "");
UNIT_ASSERT(response.node_id() != 0);
sessionId = response.session_id();
};

Expand Down