Skip to content

Do not fill tables for prepared query on compilation failure (#8210) #9910

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
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
8 changes: 4 additions & 4 deletions ydb/core/kqp/compile_service/kqp_compile_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,9 +450,9 @@ class TKqpCompileActor : public TActorBootstrapped<TKqpCompileActor> {
}

void FillCompileResult(std::unique_ptr<NKikimrKqp::TPreparedQuery> preparingQuery, NKikimrKqp::EQueryType queryType,
bool allowCache) {
bool allowCache, bool success) {
auto preparedQueryHolder = std::make_shared<TPreparedQueryHolder>(
preparingQuery.release(), AppData()->FunctionRegistry);
preparingQuery.release(), AppData()->FunctionRegistry, !success);
preparedQueryHolder->MutableLlvmSettings().Fill(Config, queryType);
KqpCompileResult->PreparedQuery = preparedQueryHolder;
KqpCompileResult->AllowCache = CanCacheQuery(KqpCompileResult->PreparedQuery->GetPhysicalQuery()) && allowCache;
Expand Down Expand Up @@ -501,7 +501,7 @@ class TKqpCompileActor : public TActorBootstrapped<TKqpCompileActor> {

if (status == Ydb::StatusIds::SUCCESS) {
YQL_ENSURE(kqpResult.PreparingQuery);
FillCompileResult(std::move(kqpResult.PreparingQuery), queryType, kqpResult.AllowCache);
FillCompileResult(std::move(kqpResult.PreparingQuery), queryType, kqpResult.AllowCache, true);

auto now = TInstant::Now();
auto duration = now - StartTime;
Expand All @@ -512,7 +512,7 @@ class TKqpCompileActor : public TActorBootstrapped<TKqpCompileActor> {
<< ", duration: " << duration);
} else {
if (kqpResult.PreparingQuery) {
FillCompileResult(std::move(kqpResult.PreparingQuery), queryType, kqpResult.AllowCache);
FillCompileResult(std::move(kqpResult.PreparingQuery), queryType, kqpResult.AllowCache, false);
}

LOG_ERROR_S(ctx, NKikimrServices::KQP_COMPILE_ACTOR, "Compilation failed"
Expand Down
7 changes: 6 additions & 1 deletion ydb/core/kqp/query_data/kqp_prepared_query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ const NKikimr::NKqp::TStagePredictor& TKqpPhyTxHolder::GetCalculationPredictor(c
}

TPreparedQueryHolder::TPreparedQueryHolder(NKikimrKqp::TPreparedQuery* proto,
const NKikimr::NMiniKQL::IFunctionRegistry* functionRegistry)
const NKikimr::NMiniKQL::IFunctionRegistry* functionRegistry, bool noFillTables)
: Proto(proto)
, Alloc(nullptr)
, TableConstInfoById(MakeIntrusive<TTableConstInfoMap>())
Expand All @@ -164,6 +164,11 @@ TPreparedQueryHolder::TPreparedQueryHolder(NKikimrKqp::TPreparedQuery* proto,
Alloc = std::make_shared<TPreparedQueryAllocHolder>(functionRegistry);
}

// In case of some compilation failures filling tables may produce new problems which may replace original error messages.
if (noFillTables) {
return;
}

THashSet<TString> tablesSet;
const auto& phyQuery = Proto->GetPhysicalQuery();
Transactions.reserve(phyQuery.TransactionsSize());
Expand Down
5 changes: 4 additions & 1 deletion ydb/core/kqp/query_data/kqp_prepared_query.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,10 @@ class TPreparedQueryHolder {

public:

TPreparedQueryHolder(NKikimrKqp::TPreparedQuery* proto, const NKikimr::NMiniKQL::IFunctionRegistry* functionRegistry);
TPreparedQueryHolder(
NKikimrKqp::TPreparedQuery* proto,
const NKikimr::NMiniKQL::IFunctionRegistry* functionRegistry,
bool noFillTables = false);
~TPreparedQueryHolder();

using TConstPtr = std::shared_ptr<const TPreparedQueryHolder>;
Expand Down
Loading