Skip to content

Commit 3a7f902

Browse files
authored
Improve Too big attachment fallback message (ydb-platform#47062)
1 parent 549ed3d commit 3a7f902

1 file changed

Lines changed: 28 additions & 18 deletions

File tree

ydb/library/yql/providers/dq/provider/exec/yql_dq_exectransformer.cpp

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,8 @@ class TDqExecTransformer: public TExecTransformerBase, TCounters
522522
pathWithMd5.Md5);
523523
}
524524

525-
bool BuildUploadList(
525+
// Returns formatted error message if attachments exceed the limit; empty string otherwise.
526+
TString BuildUploadList(
526527
TUploadList* uploadList,
527528
bool localRun,
528529
TString* lambda,
@@ -537,7 +538,7 @@ class TDqExecTransformer: public TExecTransformerBase, TCounters
537538
return ret;
538539
}
539540

540-
bool BuildUploadList(
541+
TString BuildUploadList(
541542
TUploadList* uploadList,
542543
bool localRun,
543544
TExploringNodeVisitor& explorer,
@@ -581,7 +582,6 @@ class TDqExecTransformer: public TExecTransformerBase, TCounters
581582
uploadList->emplace(f);
582583
}
583584
}
584-
bool fallbackFlag = false;
585585
for (TNode* node : explorer.GetNodes()) {
586586
node->Freeze(typeEnv);
587587

@@ -733,11 +733,17 @@ class TDqExecTransformer: public TExecTransformerBase, TCounters
733733

734734
i64 dataLimit = static_cast<i64>(State->Settings->_MaxAttachmentsSize.Get().GetOrElse(TDqSettings::TDefault::MaxAttachmentsSize));
735735
if (sizeSum > dataLimit) {
736-
YQL_CLOG(WARN, ProviderDq) << "Too much data: " << sizeSum << " > " << dataLimit;
737-
fallbackFlag = true;
736+
const auto filesCount = uploadList->size();
737+
YQL_CLOG(WARN, ProviderDq) << "Too much data: " << filesCount << " file(s), " << sizeSum << " > " << dataLimit;
738+
// Keep the "Too big attachment" prefix — analytics tools parse it.
739+
return TStringBuilder()
740+
<< "Too big attachment: " << filesCount
741+
<< " file(s) attached with a total size of "
742+
<< sizeSum << " bytes, which exceeds the limit of "
743+
<< dataLimit << " bytes";
738744
}
739745

740-
return fallbackFlag;
746+
return {};
741747
}
742748

743749
TStatusCallbackPair GetLambda(
@@ -822,10 +828,8 @@ class TDqExecTransformer: public TExecTransformerBase, TCounters
822828
}
823829

824830
const bool localRun = enableLocalRun && (!State->DqGateway || (!*untrustedUdfFlag && !State->TypeCtx->ForceDq && !hasGraphParams));
825-
bool fallbackFlag = BuildUploadList(uploadList, localRun, explorer, typeEnv, files);
826-
827-
if (fallbackFlag) {
828-
YQL_CLOG(TRACE, ProviderDq) << "Fallback: " << NCommon::ExprToPrettyString(ctx, *input);
831+
if (auto error = BuildUploadList(uploadList, localRun, explorer, typeEnv, files)) {
832+
YQL_CLOG(TRACE, ProviderDq) << "Fallback: " << error << ": " << NCommon::ExprToPrettyString(ctx, *input);
829833
return Fallback();
830834
} else {
831835
*lambda = SerializeRuntimeNode(root, typeEnv);
@@ -1428,7 +1432,6 @@ class TDqExecTransformer: public TExecTransformerBase, TCounters
14281432
return SyncStatus(FallbackWithMessage(pull.Ref(), err, ctx, true));
14291433
}
14301434

1431-
bool fallbackFlag = false;
14321435
if (executionPlanner->MaxDataSizePerJob() > maxDataSizePerJob && canFallback) {
14331436
return SyncStatus(FallbackWithMessage(
14341437
pull.Ref(),
@@ -1451,13 +1454,17 @@ class TDqExecTransformer: public TExecTransformerBase, TCounters
14511454
return SyncError();
14521455
}
14531456

1457+
TString tooBigAttachmentError;
14541458
{
14551459
TScopedAlloc alloc(__LOCATION__, NKikimr::TAlignedPagePoolCounters(), State->FunctionRegistry->SupportsSizedAllocators());
14561460
TTypeEnvironment typeEnv(alloc);
14571461
for (auto& t : tasks) {
14581462
TUploadList uploadList;
14591463
TString lambda = t.GetProgram().GetRaw();
1460-
fallbackFlag |= BuildUploadList(&uploadList, localRun, &lambda, typeEnv, files);
1464+
if (auto error = BuildUploadList(&uploadList, localRun, &lambda, typeEnv, files)) {
1465+
tooBigAttachmentError = error;
1466+
break;
1467+
}
14611468
t.MutableProgram()->SetRaw(lambda);
14621469
t.MutableProgram()->SetLangVer(State->TypeCtx->LangVer);
14631470
*t.MutableProgram()->MutableRuntimeSettings() = NYql::SerializeRuntimeSettingsToProto(*State->TypeCtx->RuntimeSettings);
@@ -1475,8 +1482,8 @@ class TDqExecTransformer: public TExecTransformerBase, TCounters
14751482

14761483
MarkProgressStarted(publicIds->AllPublicIds, State->ProgressWriter);
14771484

1478-
if (fallbackFlag) {
1479-
return SyncStatus(FallbackWithMessage(pull.Ref(), "Too big attachment", ctx, true));
1485+
if (tooBigAttachmentError) {
1486+
return SyncStatus(FallbackWithMessage(pull.Ref(), tooBigAttachmentError, ctx, true));
14801487
}
14811488

14821489
IDataProvider::TFillSettings fillSettings = NCommon::GetFillSettings(pull.Ref());
@@ -1984,7 +1991,6 @@ class TDqExecTransformer: public TExecTransformerBase, TCounters
19841991
return FallbackWithMessage(*input, err, ctx, false);
19851992
}
19861993

1987-
bool fallbackFlag = false;
19881994
if (executionPlanner->MaxDataSizePerJob() > maxDataSizePerJob && canFallback) {
19891995
return FallbackWithMessage(
19901996
*input,
@@ -2006,13 +2012,17 @@ class TDqExecTransformer: public TExecTransformerBase, TCounters
20062012
return IGraphTransformer::TStatus::Error;
20072013
}
20082014

2015+
TString tooBigAttachmentError;
20092016
{
20102017
TScopedAlloc alloc(__LOCATION__, NKikimr::TAlignedPagePoolCounters(), State->FunctionRegistry->SupportsSizedAllocators());
20112018
TTypeEnvironment typeEnv(alloc);
20122019
for (auto& t : tasks) {
20132020
TUploadList uploadList;
20142021
TString lambda = t.GetProgram().GetRaw();
2015-
fallbackFlag |= BuildUploadList(&uploadList, false, &lambda, typeEnv, files);
2022+
if (auto error = BuildUploadList(&uploadList, false, &lambda, typeEnv, files)) {
2023+
tooBigAttachmentError = error;
2024+
break;
2025+
}
20162026
t.MutableProgram()->SetRaw(lambda);
20172027
t.MutableProgram()->SetLangVer(State->TypeCtx->LangVer);
20182028
*t.MutableProgram()->MutableRuntimeSettings() = NYql::SerializeRuntimeSettingsToProto(*State->TypeCtx->RuntimeSettings);
@@ -2028,8 +2038,8 @@ class TDqExecTransformer: public TExecTransformerBase, TCounters
20282038
}
20292039
}
20302040

2031-
if (fallbackFlag) {
2032-
return FallbackWithMessage(*input, "Too big attachment", ctx, false);
2041+
if (tooBigAttachmentError) {
2042+
return FallbackWithMessage(*input, tooBigAttachmentError, ctx, false);
20332043
}
20342044

20352045
if (State->Metrics) {

0 commit comments

Comments
 (0)