Skip to content

Commit ee5c3aa

Browse files
authored
Better message for data materialization error. (#2841)
1 parent f714ab4 commit ee5c3aa

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

ydb/core/kqp/executer_actor/kqp_data_executer.cpp

+10-2
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,16 @@ class TKqpDataExecuter : public TKqpExecuterBase<TKqpDataExecuter, EExecType::Da
279279

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

285293
auto issue = YqlIssue({}, TIssuesIds::KIKIMR_RESULT_UNAVAILABLE, message);
286294
ReplyErrorAndDie(Ydb::StatusIds::PRECONDITION_FAILED, issue);

ydb/core/kqp/ut/query/kqp_limits_ut.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -1034,6 +1034,24 @@ Y_UNIT_TEST_SUITE(KqpLimits) {
10341034
last = current;
10351035
}
10361036
}
1037+
1038+
Y_UNIT_TEST(QSReplySize) {
1039+
TKikimrRunner kikimr;
1040+
CreateLargeTable(kikimr, 100'000, 100, 1'000, 1'000, 1);
1041+
1042+
auto db = kikimr.GetQueryClient();
1043+
1044+
auto result = db.ExecuteQuery(R"(
1045+
UPSERT INTO KeyValue2
1046+
SELECT
1047+
KeyText AS Key,
1048+
DataText AS Value
1049+
FROM `/Root/LargeTable`;
1050+
)", NQuery::TTxControl::BeginTx().CommitTx()).ExtractValueSync();
1051+
result.GetIssues().PrintTo(Cerr);
1052+
UNIT_ASSERT_VALUES_EQUAL(result.GetStatus(), EStatus::PRECONDITION_FAILED);
1053+
UNIT_ASSERT(!to_lower(result.GetIssues().ToString()).Contains("query result"));
1054+
}
10371055
}
10381056

10391057
} // namespace NKqp

0 commit comments

Comments
 (0)