@@ -418,7 +418,7 @@ class TKqpExecuterBase : public TActorBootstrapped<TDerived> {
418
418
auto & extraData = ExtraData[computeActor];
419
419
extraData.TaskId = taskId;
420
420
extraData.Data .Swap (state.MutableExtraData ());
421
-
421
+
422
422
423
423
Stats->AddComputeActorStats (
424
424
computeActor.NodeId (),
@@ -686,7 +686,7 @@ class TKqpExecuterBase : public TActorBootstrapped<TDerived> {
686
686
if (statusCode == Ydb::StatusIds::INTERNAL_ERROR) {
687
687
InternalError (issues);
688
688
} else if (statusCode == Ydb::StatusIds::TIMEOUT) {
689
- TimeoutError (ev->Sender );
689
+ AbortExecutionAndDie (ev->Sender , NYql::NDqProto::StatusIds::TIMEOUT, " Request timeout exceeded " );
690
690
} else {
691
691
RuntimeError (NYql::NDq::DqStatusToYdbStatus (msg.GetStatusCode ()), issues);
692
692
}
@@ -1624,14 +1624,14 @@ class TKqpExecuterBase : public TActorBootstrapped<TDerived> {
1624
1624
protected:
1625
1625
void TerminateComputeActors (Ydb::StatusIds::StatusCode code, const NYql::TIssues& issues) {
1626
1626
for (const auto & task : this ->TasksGraph .GetTasks ()) {
1627
- if (task.ComputeActorId && !task. Meta . Completed ) {
1627
+ if (task.ComputeActorId ) {
1628
1628
LOG_I (" aborting compute actor execution, message: " << issues.ToOneLineString ()
1629
1629
<< " , compute actor: " << task.ComputeActorId << " , task: " << task.Id );
1630
1630
1631
1631
auto ev = MakeHolder<TEvKqp::TEvAbortExecution>(NYql::NDq::YdbStatusToDqStatus (code), issues);
1632
1632
this ->Send (task.ComputeActorId , ev.Release ());
1633
1633
} else {
1634
- LOG_I (" task: " << task.Id << " , does not have the CA id yet or is already complete " );
1634
+ LOG_I (" task: " << task.Id << " , does not have Compute ActorId yet" );
1635
1635
}
1636
1636
}
1637
1637
}
@@ -1649,6 +1649,7 @@ class TKqpExecuterBase : public TActorBootstrapped<TDerived> {
1649
1649
1650
1650
void InternalError (const NYql::TIssues& issues) {
1651
1651
LOG_E (issues.ToOneLineString ());
1652
+ TerminateComputeActors (Ydb::StatusIds::INTERNAL_ERROR, issues);
1652
1653
auto issue = NYql::YqlIssue ({}, NYql::TIssuesIds::UNEXPECTED, " Internal error while executing transaction." );
1653
1654
for (const NYql::TIssue& i : issues) {
1654
1655
issue.AddSubIssue (MakeIntrusive<NYql::TIssue>(i));
@@ -1662,13 +1663,15 @@ class TKqpExecuterBase : public TActorBootstrapped<TDerived> {
1662
1663
1663
1664
void ReplyUnavailable (const TString& message) {
1664
1665
LOG_E (" UNAVAILABLE: " << message);
1666
+ TerminateComputeActors (Ydb::StatusIds::UNAVAILABLE, message);
1665
1667
auto issue = NYql::YqlIssue ({}, NYql::TIssuesIds::KIKIMR_TEMPORARILY_UNAVAILABLE);
1666
1668
issue.AddSubIssue (new NYql::TIssue (message));
1667
1669
ReplyErrorAndDie (Ydb::StatusIds::UNAVAILABLE, issue);
1668
1670
}
1669
1671
1670
1672
void RuntimeError (Ydb::StatusIds::StatusCode code, const NYql::TIssues& issues) {
1671
1673
LOG_E (Ydb::StatusIds_StatusCode_Name (code) << " : " << issues.ToOneLineString ());
1674
+ TerminateComputeActors (code, issues);
1672
1675
ReplyErrorAndDie (code, issues);
1673
1676
}
1674
1677
@@ -1684,19 +1687,11 @@ class TKqpExecuterBase : public TActorBootstrapped<TDerived> {
1684
1687
ReplyErrorAndDie (status, &issues);
1685
1688
}
1686
1689
1687
- void TimeoutError (TActorId abortSender) {
1690
+ void AbortExecutionAndDie (TActorId abortSender, NYql::NDqProto::StatusIds::StatusCode status, const TString& message ) {
1688
1691
if (AlreadyReplied) {
1689
- LOG_E (" Timeout when we already replied - not good" << Endl << TBackTrace ().PrintToString () << Endl);
1690
1692
return ;
1691
1693
}
1692
1694
1693
- const auto status = NYql::NDqProto::StatusIds::TIMEOUT;
1694
- const TString message = " Request timeout exceeded" ;
1695
-
1696
- TerminateComputeActors (Ydb::StatusIds::TIMEOUT, message);
1697
-
1698
- AlreadyReplied = true ;
1699
-
1700
1695
LOG_E (" Abort execution: " << NYql::NDqProto::StatusIds_StatusCode_Name (status) << " ," << message);
1701
1696
if (ExecuterSpan) {
1702
1697
ExecuterSpan.EndError (TStringBuilder () << NYql::NDqProto::StatusIds_StatusCode_Name (status));
@@ -1706,24 +1701,34 @@ class TKqpExecuterBase : public TActorBootstrapped<TDerived> {
1706
1701
1707
1702
// TEvAbortExecution can come from either ComputeActor or SessionActor (== Target).
1708
1703
if (abortSender != Target) {
1709
- auto abortEv = MakeHolder<TEvKqp::TEvAbortExecution>(status, message );
1704
+ auto abortEv = MakeHolder<TEvKqp::TEvAbortExecution>(status, " Request timeout exceeded " );
1710
1705
this ->Send (Target, abortEv.Release ());
1711
1706
}
1712
1707
1708
+ AlreadyReplied = true ;
1713
1709
LOG_E (" Sending timeout response to: " << Target);
1710
+ this ->Send (Target, ResponseEv.release ());
1714
1711
1715
- this ->Shutdown ();
1712
+ Request.Transactions .crop (0 );
1713
+ TerminateComputeActors (Ydb::StatusIds::TIMEOUT, message);
1714
+ this ->PassAway ();
1716
1715
}
1717
1716
1718
1717
virtual void ReplyErrorAndDie (Ydb::StatusIds::StatusCode status,
1719
1718
google::protobuf::RepeatedPtrField<Ydb::Issue::IssueMessage>* issues)
1720
1719
{
1721
1720
if (AlreadyReplied) {
1722
- LOG_E (" Error when we already replied - not good" << Endl << TBackTrace ().PrintToString () << Endl);
1723
1721
return ;
1724
1722
}
1725
1723
1726
- TerminateComputeActors (status, " Terminate execution" );
1724
+ if (Planner) {
1725
+ for (auto computeActor : Planner->GetPendingComputeActors ()) {
1726
+ LOG_D (" terminate compute actor " << computeActor.first );
1727
+
1728
+ auto ev = MakeHolder<TEvKqp::TEvAbortExecution>(NYql::NDq::YdbStatusToDqStatus (status), " Terminate execution" );
1729
+ this ->Send (computeActor.first , ev.Release ());
1730
+ }
1731
+ }
1727
1732
1728
1733
AlreadyReplied = true ;
1729
1734
auto & response = *ResponseEv->Record .MutableResponse ();
@@ -1749,7 +1754,9 @@ class TKqpExecuterBase : public TActorBootstrapped<TDerived> {
1749
1754
ExecuterSpan.EndError (response.DebugString ());
1750
1755
ExecuterStateSpan.EndError (response.DebugString ());
1751
1756
1752
- this ->Shutdown ();
1757
+ Request.Transactions .crop (0 );
1758
+ this ->Send (Target, ResponseEv.release ());
1759
+ this ->PassAway ();
1753
1760
}
1754
1761
1755
1762
protected:
@@ -1817,46 +1824,7 @@ class TKqpExecuterBase : public TActorBootstrapped<TDerived> {
1817
1824
}
1818
1825
1819
1826
protected:
1820
- // Introduced separate method from `PassAway()` - to not get confused with expectations from other actors,
1821
- // that `PassAway()` should kill actor immediately.
1822
- virtual void Shutdown () {
1823
- PassAway ();
1824
- }
1825
-
1826
1827
void PassAway () override {
1827
- YQL_ENSURE (AlreadyReplied && ResponseEv);
1828
-
1829
- // Fill response stats
1830
- {
1831
- auto & response = *ResponseEv->Record .MutableResponse ();
1832
-
1833
- YQL_ENSURE (Stats);
1834
-
1835
- ReportEventElapsedTime ();
1836
-
1837
- Stats->FinishTs = TInstant::Now ();
1838
- Stats->Finish ();
1839
-
1840
- if (Stats->CollectStatsByLongTasks || CollectFullStats (Request.StatsMode )) {
1841
- response.MutableResult ()->MutableStats ()->ClearTxPlansWithStats ();
1842
- for (ui32 txId = 0 ; txId < Request.Transactions .size (); ++txId) {
1843
- const auto & tx = Request.Transactions [txId].Body ;
1844
- auto planWithStats = AddExecStatsToTxPlan (tx->GetPlan (), response.GetResult ().GetStats ());
1845
- response.MutableResult ()->MutableStats ()->AddTxPlansWithStats (planWithStats);
1846
- }
1847
- }
1848
-
1849
- if (Stats->CollectStatsByLongTasks ) {
1850
- const auto & txPlansWithStats = response.GetResult ().GetStats ().GetTxPlansWithStats ();
1851
- if (!txPlansWithStats.empty ()) {
1852
- LOG_N (" Full stats: " << response.GetResult ().GetStats ());
1853
- }
1854
- }
1855
- }
1856
-
1857
- Request.Transactions .crop (0 );
1858
- this ->Send (Target, ResponseEv.release ());
1859
-
1860
1828
for (auto channelPair: ResultChannelProxies) {
1861
1829
LOG_D (" terminate result channel " << channelPair.first << " proxy at " << channelPair.second ->SelfId ());
1862
1830
@@ -1877,11 +1845,12 @@ class TKqpExecuterBase : public TActorBootstrapped<TDerived> {
1877
1845
1878
1846
if (KqpTableResolverId) {
1879
1847
this ->Send (KqpTableResolverId, new TEvents::TEvPoison);
1848
+ this ->Send (this ->SelfId (), new TEvents::TEvPoison);
1849
+ LOG_T (" Terminate, become ZombieState" );
1850
+ this ->Become (&TKqpExecuterBase::ZombieState);
1851
+ } else {
1852
+ IActor::PassAway ();
1880
1853
}
1881
-
1882
- this ->Send (this ->SelfId (), new TEvents::TEvPoison);
1883
- LOG_T (" Terminate, become ZombieState" );
1884
- this ->Become (&TKqpExecuterBase::ZombieState);
1885
1854
}
1886
1855
1887
1856
STATEFN (ZombieState) {
0 commit comments