@@ -64,12 +64,10 @@ namespace NKqp {
6464#define LOG_E (stream ) LOG_ERROR_S(*TlsActivationContext, NKikimrServices::KQP_EXECUTER, " ActorId: " << SelfId() << " TxId: " << TxId << " . " << " Ctx: " << *GetUserRequestContext () << ". " << stream)
6565#define LOG_C (stream ) LOG_CRIT_S(*TlsActivationContext, NKikimrServices::KQP_EXECUTER, " ActorId: " << SelfId() << " TxId: " << TxId << " . " << " Ctx: " << *GetUserRequestContext () << ". " << stream)
6666
67- enum class EExecType {
68- Data,
69- Scan
70- };
67+ using EExecType = TEvKqpExecuter::TEvTxResponse::EExecutionType;
7168
7269const ui64 MaxTaskSize = 48_MB;
70+ constexpr ui64 PotentialUnsigned64OverflowLimit = (std::numeric_limits<ui64>::max() >> 1 );
7371
7472std::pair<TString, TString> SerializeKqpTasksParametersForOlap (const TStageInfo& stageInfo, const TTask& task);
7573
@@ -114,6 +112,7 @@ struct TEvPrivate {
114112
115113template <class TDerived , EExecType ExecType>
116114class TKqpExecuterBase : public TActorBootstrapped <TDerived> {
115+ static_assert (ExecType == EExecType::Data || ExecType == EExecType::Scan);
117116public:
118117 TKqpExecuterBase (IKqpGateway::TExecPhysicalRequest&& request, const TString& database,
119118 const TIntrusiveConstPtr<NACLib::TUserToken>& userToken,
@@ -140,7 +139,7 @@ class TKqpExecuterBase : public TActorBootstrapped<TDerived> {
140139 TasksGraph.GetMeta ().Database = Database;
141140 TasksGraph.GetMeta ().ChannelTransportVersion = chanTransportVersion;
142141 TasksGraph.GetMeta ().UserRequestContext = userRequestContext;
143- ResponseEv = std::make_unique<TEvKqpExecuter::TEvTxResponse>(Request.TxAlloc );
142+ ResponseEv = std::make_unique<TEvKqpExecuter::TEvTxResponse>(Request.TxAlloc , ExecType );
144143 ResponseEv->Orbit = std::move (Request.Orbit );
145144 Stats = std::make_unique<TQueryExecutionStats>(Request.StatsMode , &TasksGraph,
146145 ResponseEv->Record .MutableResponse ()->MutableResult ()->MutableStats ());
@@ -360,7 +359,7 @@ class TKqpExecuterBase : public TActorBootstrapped<TDerived> {
360359 ui64 seqNo = ev->Get ()->Record .GetSeqNo ();
361360 i64 freeSpace = ev->Get ()->Record .GetFreeSpace ();
362361
363- LOG_ERROR_S (*NActors::TlsActivationContext, NKikimrServices::KQP_EXECUTER, " TxId: " << TxId
362+ LOG_DEBUG_S (*NActors::TlsActivationContext, NKikimrServices::KQP_EXECUTER, " TxId: " << TxId
364363 << " , send ack to channelId: " << channelId
365364 << " , seqNo: " << seqNo
366365 << " , enough: " << ev->Get ()->Record .GetEnough ()
@@ -798,6 +797,9 @@ class TKqpExecuterBase : public TActorBootstrapped<TDerived> {
798797
799798 auto ru = NRuCalc::CalcRequestUnit (consumption);
800799
800+ YQL_ENSURE (consumption.ReadIOStat .Rows < PotentialUnsigned64OverflowLimit);
801+ YQL_ENSURE (ru < PotentialUnsigned64OverflowLimit);
802+
801803 // Some heuristic to reduce overprice due to round part stats
802804 if (ru <= 100 && !force)
803805 return ;
@@ -1661,6 +1663,10 @@ class TKqpExecuterBase : public TActorBootstrapped<TDerived> {
16611663 }
16621664
16631665 void AbortExecutionAndDie (TActorId abortSender, NYql::NDqProto::StatusIds::StatusCode status, const TString& message) {
1666+ if (AlreadyReplied) {
1667+ return ;
1668+ }
1669+
16641670 LOG_E (" Abort execution: " << NYql::NDqProto::StatusIds_StatusCode_Name (status) << " ," << message);
16651671 if (ExecuterSpan) {
16661672 ExecuterSpan.EndError (TStringBuilder () << NYql::NDqProto::StatusIds_StatusCode_Name (status));
@@ -1674,6 +1680,7 @@ class TKqpExecuterBase : public TActorBootstrapped<TDerived> {
16741680 this ->Send (Target, abortEv.Release ());
16751681 }
16761682
1683+ AlreadyReplied = true ;
16771684 LOG_E (" Sending timeout response to: " << Target);
16781685 this ->Send (Target, ResponseEv.release ());
16791686
@@ -1685,6 +1692,10 @@ class TKqpExecuterBase : public TActorBootstrapped<TDerived> {
16851692 virtual void ReplyErrorAndDie (Ydb::StatusIds::StatusCode status,
16861693 google::protobuf::RepeatedPtrField<Ydb::Issue::IssueMessage>* issues)
16871694 {
1695+ if (AlreadyReplied) {
1696+ return ;
1697+ }
1698+
16881699 if (Planner) {
16891700 for (auto computeActor : Planner->GetPendingComputeActors ()) {
16901701 LOG_D (" terminate compute actor " << computeActor.first );
@@ -1694,6 +1705,7 @@ class TKqpExecuterBase : public TActorBootstrapped<TDerived> {
16941705 }
16951706 }
16961707
1708+ AlreadyReplied = true ;
16971709 auto & response = *ResponseEv->Record .MutableResponse ();
16981710
16991711 response.SetStatus (status);
@@ -1907,6 +1919,8 @@ class TKqpExecuterBase : public TActorBootstrapped<TDerived> {
19071919 THashMap<ui64, TActorId> ResultChannelToComputeActor;
19081920 THashMap<NYql::NDq::TStageId, THashMap<ui64, TShardInfo>> SourceScanStageIdToParititions;
19091921
1922+ bool AlreadyReplied = false ;
1923+
19101924private:
19111925 static constexpr TDuration ResourceUsageUpdateInterval = TDuration::MilliSeconds(100 );
19121926};
0 commit comments