Skip to content

Commit f9f3237

Browse files
committed
Always detach forget operation
1 parent 2dbe2ec commit f9f3237

File tree

1 file changed

+27
-15
lines changed

1 file changed

+27
-15
lines changed

ydb/core/kqp/proxy_service/kqp_script_executions.cpp

+27-15
Original file line numberDiff line numberDiff line change
@@ -839,14 +839,36 @@ class TForgetScriptExecutionOperationQueryActor : public TQueryBase {
839839
FROM `.metadata/script_executions`
840840
WHERE database = $database AND execution_id = $execution_id;
841841
842+
DELETE
843+
FROM `.metadata/script_execution_leases`
844+
WHERE database = $database AND execution_id = $execution_id;
845+
)";
846+
847+
NYdb::TParamsBuilder params;
848+
params
849+
.AddParam("$database")
850+
.Utf8(Database)
851+
.Build()
852+
.AddParam("$execution_id")
853+
.Utf8(ExecutionId)
854+
.Build();
855+
856+
RunDataQuery(sql, &params);
857+
SetQueryResultHandler(&TForgetScriptExecutionOperationQueryActor::OnOperationDeleted, "Forget script execution operation");
858+
}
859+
860+
void OnOperationDeleted() {
861+
SendResponse(Ydb::StatusIds::SUCCESS, {});
862+
863+
TString sql = R"(
864+
-- TForgetScriptExecutionOperationQueryActor::OnOperationDeleted
865+
DECLARE $database AS Text;
866+
DECLARE $execution_id AS Text;
867+
842868
SELECT MAX(result_set_id) AS max_result_set_id, MAX(row_id) AS max_row_id
843869
FROM `.metadata/result_sets`
844870
WHERE database = $database AND execution_id = $execution_id AND
845871
(expire_at > CurrentUtcTimestamp() OR expire_at IS NULL);
846-
847-
DELETE
848-
FROM `.metadata/script_execution_leases`
849-
WHERE database = $database AND execution_id = $execution_id;
850872
)";
851873

852874
NYdb::TParamsBuilder params;
@@ -859,7 +881,7 @@ class TForgetScriptExecutionOperationQueryActor : public TQueryBase {
859881
.Build();
860882

861883
RunDataQuery(sql, &params);
862-
SetQueryResultHandler(&TForgetScriptExecutionOperationQueryActor::OnGetResultsInfo, "Forget script execution operation");
884+
SetQueryResultHandler(&TForgetScriptExecutionOperationQueryActor::OnGetResultsInfo, "Get results info");
863885
}
864886

865887
void OnGetResultsInfo() {
@@ -890,16 +912,6 @@ class TForgetScriptExecutionOperationQueryActor : public TQueryBase {
890912
}
891913
MaxRowId = *maxRowId;
892914

893-
if (MaxRowId >= NumberRowsInBatch) {
894-
TStringBuilder message = TStringBuilder() << "Query result rows count is " << MaxRowId + 1;
895-
if (*maxResultSetId > 0) {
896-
message << " in " << *maxResultSetId + 1 << " result sets";
897-
}
898-
NYql::TIssue issue(message << ", that is larger than allowed limit " << MAX_NUMBER_ROWS_IN_BATCH << " rows for one time forget, results will be forgotten in the background process");
899-
issue.SetCode(NYql::DEFAULT_ERROR, NYql::TSeverityIds::S_INFO);
900-
SendResponse(Ydb::StatusIds::SUCCESS, {issue});
901-
}
902-
903915
DeleteScriptResults();
904916
}
905917

0 commit comments

Comments
 (0)