Skip to content

Better message for data materialization error. #2841

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
Mar 18, 2024
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
12 changes: 10 additions & 2 deletions ydb/core/kqp/executer_actor/kqp_data_executer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,16 @@ class TKqpDataExecuter : public TKqpExecuterBase<TKqpDataExecuter, EExecType::Da

auto resultSize = ResponseEv->GetByteSize();
if (resultSize > (int)ReplySizeLimit) {
TString message = TStringBuilder() << "Query result size limit exceeded. ("
<< resultSize << " > " << ReplySizeLimit << ")";
TString message;
if (ResponseEv->TxResults.size() == 1 && !ResponseEv->TxResults[0].QueryResultIndex.Defined()) {
message = TStringBuilder() << "Intermediate data materialization exceeded size limit"
<< " (" << resultSize << " > " << ReplySizeLimit << ")."
<< " This usually happens when trying to write large amounts of data or to perform lookup"
<< " by big collection of keys in single query. Consider using smaller batches of data.";
} else {
message = TStringBuilder() << "Query result size limit exceeded. ("
<< resultSize << " > " << ReplySizeLimit << ")";
}

auto issue = YqlIssue({}, TIssuesIds::KIKIMR_RESULT_UNAVAILABLE, message);
ReplyErrorAndDie(Ydb::StatusIds::PRECONDITION_FAILED, issue);
Expand Down
18 changes: 18 additions & 0 deletions ydb/core/kqp/ut/query/kqp_limits_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,24 @@ Y_UNIT_TEST_SUITE(KqpLimits) {
last = current;
}
}

Y_UNIT_TEST(QSReplySize) {
TKikimrRunner kikimr;
CreateLargeTable(kikimr, 100'000, 100, 1'000, 1'000, 1);

auto db = kikimr.GetQueryClient();

auto result = db.ExecuteQuery(R"(
UPSERT INTO KeyValue2
SELECT
KeyText AS Key,
DataText AS Value
FROM `/Root/LargeTable`;
)", NQuery::TTxControl::BeginTx().CommitTx()).ExtractValueSync();
result.GetIssues().PrintTo(Cerr);
UNIT_ASSERT_VALUES_EQUAL(result.GetStatus(), EStatus::PRECONDITION_FAILED);
UNIT_ASSERT(!to_lower(result.GetIssues().ToString()).Contains("query result"));
}
}

} // namespace NKqp
Expand Down