Skip to content

Commit e818190

Browse files
committed
add info into log
1 parent 15698f5 commit e818190

File tree

4 files changed

+43
-3
lines changed

4 files changed

+43
-3
lines changed

ydb/core/kqp/common/simple/query_id.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <google/protobuf/util/message_differencer.h>
55

66
#include <util/generic/yexception.h>
7+
#include <util/string/escape.h>
78

89
#include <memory>
910

@@ -74,4 +75,25 @@ bool TKqpQueryId::operator==(const TKqpQueryId& other) const {
7475
return true;
7576
}
7677

78+
TString TKqpQueryId::SerializeToString() const {
79+
TStringBuilder result = TStringBuilder() << "{"
80+
<< "Cluster: " << Cluster << ", "
81+
<< "Database: " << Database << ", "
82+
<< "UserSid: " << UserSid << ", "
83+
<< "Text: " << EscapeC(Text) << ", "
84+
<< "Settings: " << Settings.SerializeToString() << ", ";
85+
if (QueryParameterTypes) {
86+
result << "QueryParameterTypes: [";
87+
for (const auto& param : *QueryParameterTypes) {
88+
result << "name: " << param.first << ", type: " << param.second.ShortDebugString();
89+
}
90+
result << "], ";
91+
} else {
92+
result << "QueryParameterTypes: <empty>, ";
93+
}
94+
95+
result << "GUCSettings: " << GUCSettings.SerializeToString() << "}";
96+
return result;
97+
}
98+
7799
} // namespace NKikimr::NKqp

ydb/core/kqp/common/simple/query_id.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ struct TKqpQueryId {
4444
GUCSettings.GetHash());
4545
return THash<decltype(tuple)>()(tuple);
4646
}
47+
48+
TString SerializeToString() const;
4749
};
4850
} // namespace NKikimr::NKqp
4951

ydb/core/kqp/common/simple/settings.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
#include <ydb/core/protos/kqp.pb.h>
44
#include <ydb/public/api/protos/ydb_query.pb.h>
55

6+
#include <util/generic/string.h>
67
#include <util/str_stl.h>
8+
#include <util/string/builder.h>
79

810
#include <tuple>
911

@@ -39,6 +41,14 @@ struct TKqpQuerySettings {
3941
auto tuple = std::make_tuple(DocumentApiRestricted, IsInternalCall, QueryType, Syntax);
4042
return THash<decltype(tuple)>()(tuple);
4143
}
44+
45+
TString SerializeToString() const {
46+
TStringBuilder result = TStringBuilder() << "{"
47+
<< "DocumentApiRestricted: " << DocumentApiRestricted << ", "
48+
<< "IsInternalCall: " << IsInternalCall << ", "
49+
<< "QueryType: " << QueryType << "}";
50+
return result;
51+
}
4252
};
4353

4454
} // namespace NKikimr::NKqp

ydb/core/kqp/compile_service/kqp_compile_service.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,7 @@ class TKqpCompileService : public TActorBootstrapped<TKqpCompileService> {
679679
Y_ENSURE(query.UserSid == userSid);
680680
}
681681

682+
LOG_DEBUG_S(ctx, NKikimrServices::KQP_COMPILE_SERVICE, "Try to find query by queryId, queryId: " << query.SerializeToString());
682683
auto compileResult = QueryCache.FindByQuery(query, request.KeepInCache);
683684
if (HasTempTablesNameClashes(compileResult, request.TempTablesState)) {
684685
compileResult = nullptr;
@@ -946,8 +947,11 @@ class TKqpCompileService : public TActorBootstrapped<TKqpCompileService> {
946947
if (QueryCache.FindByUid(compileResult->Uid, false)) {
947948
QueryCache.Replace(compileResult);
948949
} else if (keepInCache) {
949-
if (compileResult->Query && QueryCache.FindByQuery(*compileResult->Query, keepInCache)) {
950-
LOG_ERROR_S(ctx, NKikimrServices::KQP_COMPILE_SERVICE, "Trying to insert query into compile cache when it is already there");
950+
if (compileResult->Query) {
951+
LOG_DEBUG_S(ctx, NKikimrServices::KQP_COMPILE_SERVICE, "Insert query into compile cache, queryId: " << compileResult->Query->SerializeToString());
952+
if (QueryCache.FindByQuery(*compileResult->Query, keepInCache)) {
953+
LOG_ERROR_S(ctx, NKikimrServices::KQP_COMPILE_SERVICE, "Trying to insert query into compile cache when it is already there");
954+
}
951955
}
952956
if (QueryCache.Insert(compileResult, TableServiceConfig.GetEnableAstCache(), isPerStatementExecution)) {
953957
Counters->CompileQueryCacheEvicted->Inc();
@@ -964,6 +968,8 @@ class TKqpCompileService : public TActorBootstrapped<TKqpCompileService> {
964968
YQL_ENSURE(queryAst.Ast);
965969
YQL_ENSURE(queryAst.Ast->IsOk());
966970
YQL_ENSURE(queryAst.Ast->Root);
971+
LOG_DEBUG_S(ctx, NKikimrServices::KQP_COMPILE_SERVICE, "Try to find query by ast, queryId: " << compileRequest.Query.SerializeToString()
972+
<< ", ast: " << queryAst.Ast->Root->ToString());
967973
auto compileResult = QueryCache.FindByAst(compileRequest.Query, *queryAst.Ast, compileRequest.CompileSettings.KeepInCache);
968974

969975
if (HasTempTablesNameClashes(compileResult, compileRequest.TempTablesState)) {
@@ -1054,10 +1060,10 @@ class TKqpCompileService : public TActorBootstrapped<TKqpCompileService> {
10541060
if (compileResult->Ast && QueryCache.FindByAst(query, *compileResult->Ast, keepInCache)) {
10551061
return false;
10561062
}
1057-
LOG_DEBUG_S(ctx, NKikimrServices::KQP_COMPILE_SERVICE, "Insert preparing query with params");
10581063
auto newCompileResult = TKqpCompileResult::Make(CreateGuidAsString(), compileResult->Status, compileResult->Issues, compileResult->MaxReadType, std::move(query), compileResult->Ast);
10591064
newCompileResult->AllowCache = compileResult->AllowCache;
10601065
newCompileResult->PreparedQuery = compileResult->PreparedQuery;
1066+
LOG_DEBUG_S(ctx, NKikimrServices::KQP_COMPILE_SERVICE, "Insert preparing query with params, queryId: " << query.SerializeToString());
10611067
return QueryCache.Insert(newCompileResult, TableServiceConfig.GetEnableAstCache(), isPerStatementExecution);
10621068
}
10631069

0 commit comments

Comments
 (0)