Skip to content
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

YYQ-3398 fixed result set size counting #6165

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
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ using TEvFetchScriptResultsRequest = TGrpcRequestNoOperationCall<Ydb::Query::Fet
Ydb::Query::FetchScriptResultsResponse>;

constexpr i64 MAX_ROWS_LIMIT = 1000;
constexpr i64 MAX_SIZE_LIMIT = 60_MB;
constexpr i64 MAX_SIZE_LIMIT = 50_MB;

class TFetchScriptResultsRPC : public TRpcRequestActor<TFetchScriptResultsRPC, TEvFetchScriptResultsRequest, false> {
public:
Expand Down
11 changes: 9 additions & 2 deletions ydb/core/kqp/proxy_service/kqp_script_executions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2157,9 +2157,9 @@ class TGetScriptExecutionResultQueryActor : public TQueryBase {
Finish(Ydb::StatusIds::INTERNAL_ERROR, "Result set row is empty");
return;
}

i64 rowSize = serializedRow->size();
if (SizeLimit && ResultSet.rows_size() && ResultSetSize + rowSize > SizeLimit) {
if (SizeLimit && ResultSet.rows_size() && ResultSetSize + rowSize + AdditionalRowSize > SizeLimit) {
CancelFetchQuery();
return;
}
Expand All @@ -2174,6 +2174,12 @@ class TGetScriptExecutionResultQueryActor : public TQueryBase {
Finish(Ydb::StatusIds::INTERNAL_ERROR, "Result set row is corrupted");
return;
}

// Initialize AdditionalRowSize
if (ResultSet.rows_size() == 1) {
AdditionalRowSize = static_cast<i64>(ResultSet.ByteSizeLong()) - ResultSetSize;
}
ResultSetSize += AdditionalRowSize;
}

if (TInstant::Now() + TDuration::Seconds(5) + GetAverageTime() >= Deadline) {
Expand Down Expand Up @@ -2209,6 +2215,7 @@ class TGetScriptExecutionResultQueryActor : public TQueryBase {
const TInstant Deadline;

i64 ResultSetSize = 0;
i64 AdditionalRowSize = 0;
Ydb::ResultSet ResultSet;
bool HasMoreResults = false;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1774,6 +1774,10 @@ Y_UNIT_TEST_SUITE(KqpFederatedQuery) {
}

Y_UNIT_TEST(ExecuteScriptWithLargeFile) {
ExecuteSelectQuery("test_bucket_execute_script_with_large_file", 65_MB, 500000);
}

Y_UNIT_TEST(ExecuteScriptWithThinFile) {
ExecuteSelectQuery("test_bucket_execute_script_with_large_file", 5_MB, 500000);
}
}
Expand Down
Loading