@@ -668,7 +668,7 @@ class TKqpExecuterBase : public TActorBootstrapped<TDerived> {
668
668
if (statusCode == Ydb::StatusIds::INTERNAL_ERROR) {
669
669
InternalError (issues);
670
670
} else if (statusCode == Ydb::StatusIds::TIMEOUT) {
671
- TimeoutError (ev->Sender );
671
+ AbortExecutionAndDie (ev->Sender , NYql::NDqProto::StatusIds::TIMEOUT, " Request timeout exceeded " );
672
672
} else {
673
673
RuntimeError (NYql::NDq::DqStatusToYdbStatus (msg.GetStatusCode ()), issues);
674
674
}
@@ -1601,14 +1601,14 @@ class TKqpExecuterBase : public TActorBootstrapped<TDerived> {
1601
1601
protected:
1602
1602
void TerminateComputeActors (Ydb::StatusIds::StatusCode code, const NYql::TIssues& issues) {
1603
1603
for (const auto & task : this ->TasksGraph .GetTasks ()) {
1604
- if (task.ComputeActorId && !task. Meta . Completed ) {
1604
+ if (task.ComputeActorId ) {
1605
1605
LOG_I (" aborting compute actor execution, message: " << issues.ToOneLineString ()
1606
1606
<< " , compute actor: " << task.ComputeActorId << " , task: " << task.Id );
1607
1607
1608
1608
auto ev = MakeHolder<TEvKqp::TEvAbortExecution>(NYql::NDq::YdbStatusToDqStatus (code), issues);
1609
1609
this ->Send (task.ComputeActorId , ev.Release ());
1610
1610
} else {
1611
- LOG_I (" task: " << task.Id << " , does not have the CA id yet or is already complete " );
1611
+ LOG_I (" task: " << task.Id << " , does not have Compute ActorId yet" );
1612
1612
}
1613
1613
}
1614
1614
}
@@ -1626,6 +1626,7 @@ class TKqpExecuterBase : public TActorBootstrapped<TDerived> {
1626
1626
1627
1627
void InternalError (const NYql::TIssues& issues) {
1628
1628
LOG_E (issues.ToOneLineString ());
1629
+ TerminateComputeActors (Ydb::StatusIds::INTERNAL_ERROR, issues);
1629
1630
auto issue = NYql::YqlIssue ({}, NYql::TIssuesIds::UNEXPECTED, " Internal error while executing transaction." );
1630
1631
for (const NYql::TIssue& i : issues) {
1631
1632
issue.AddSubIssue (MakeIntrusive<NYql::TIssue>(i));
@@ -1639,13 +1640,15 @@ class TKqpExecuterBase : public TActorBootstrapped<TDerived> {
1639
1640
1640
1641
void ReplyUnavailable (const TString& message) {
1641
1642
LOG_E (" UNAVAILABLE: " << message);
1643
+ TerminateComputeActors (Ydb::StatusIds::UNAVAILABLE, message);
1642
1644
auto issue = NYql::YqlIssue ({}, NYql::TIssuesIds::KIKIMR_TEMPORARILY_UNAVAILABLE);
1643
1645
issue.AddSubIssue (new NYql::TIssue (message));
1644
1646
ReplyErrorAndDie (Ydb::StatusIds::UNAVAILABLE, issue);
1645
1647
}
1646
1648
1647
1649
void RuntimeError (Ydb::StatusIds::StatusCode code, const NYql::TIssues& issues) {
1648
1650
LOG_E (Ydb::StatusIds_StatusCode_Name (code) << " : " << issues.ToOneLineString ());
1651
+ TerminateComputeActors (code, issues);
1649
1652
ReplyErrorAndDie (code, issues);
1650
1653
}
1651
1654
@@ -1661,19 +1664,11 @@ class TKqpExecuterBase : public TActorBootstrapped<TDerived> {
1661
1664
ReplyErrorAndDie (status, &issues);
1662
1665
}
1663
1666
1664
- void TimeoutError (TActorId abortSender) {
1667
+ void AbortExecutionAndDie (TActorId abortSender, NYql::NDqProto::StatusIds::StatusCode status, const TString& message ) {
1665
1668
if (AlreadyReplied) {
1666
- LOG_E (" Timeout when we already replied - not good" << Endl << TBackTrace ().PrintToString () << Endl);
1667
1669
return ;
1668
1670
}
1669
1671
1670
- const auto status = NYql::NDqProto::StatusIds::TIMEOUT;
1671
- const TString message = " Request timeout exceeded" ;
1672
-
1673
- TerminateComputeActors (Ydb::StatusIds::TIMEOUT, message);
1674
-
1675
- AlreadyReplied = true ;
1676
-
1677
1672
LOG_E (" Abort execution: " << NYql::NDqProto::StatusIds_StatusCode_Name (status) << " ," << message);
1678
1673
if (ExecuterSpan) {
1679
1674
ExecuterSpan.EndError (TStringBuilder () << NYql::NDqProto::StatusIds_StatusCode_Name (status));
@@ -1683,14 +1678,17 @@ class TKqpExecuterBase : public TActorBootstrapped<TDerived> {
1683
1678
1684
1679
// TEvAbortExecution can come from either ComputeActor or SessionActor (== Target).
1685
1680
if (abortSender != Target) {
1686
- auto abortEv = MakeHolder<TEvKqp::TEvAbortExecution>(status, message );
1681
+ auto abortEv = MakeHolder<TEvKqp::TEvAbortExecution>(status, " Request timeout exceeded " );
1687
1682
this ->Send (Target, abortEv.Release ());
1688
1683
}
1689
1684
1685
+ AlreadyReplied = true ;
1690
1686
LOG_E (" Sending timeout response to: " << Target);
1687
+ this ->Send (Target, ResponseEv.release ());
1691
1688
1692
1689
Request.Transactions .crop (0 );
1693
- this ->Shutdown ();
1690
+ TerminateComputeActors (Ydb::StatusIds::TIMEOUT, message);
1691
+ this ->PassAway ();
1694
1692
}
1695
1693
1696
1694
void FillResponseStats (Ydb::StatusIds::StatusCode status) {
@@ -1725,11 +1723,17 @@ class TKqpExecuterBase : public TActorBootstrapped<TDerived> {
1725
1723
google::protobuf::RepeatedPtrField<Ydb::Issue::IssueMessage>* issues)
1726
1724
{
1727
1725
if (AlreadyReplied) {
1728
- LOG_E (" Error when we already replied - not good" << Endl << TBackTrace ().PrintToString () << Endl);
1729
1726
return ;
1730
1727
}
1731
1728
1732
- TerminateComputeActors (status, " Terminate execution" );
1729
+ if (Planner) {
1730
+ for (auto computeActor : Planner->GetPendingComputeActors ()) {
1731
+ LOG_D (" terminate compute actor " << computeActor.first );
1732
+
1733
+ auto ev = MakeHolder<TEvKqp::TEvAbortExecution>(NYql::NDq::YdbStatusToDqStatus (status), " Terminate execution" );
1734
+ this ->Send (computeActor.first , ev.Release ());
1735
+ }
1736
+ }
1733
1737
1734
1738
AlreadyReplied = true ;
1735
1739
auto & response = *ResponseEv->Record .MutableResponse ();
@@ -1756,7 +1760,8 @@ class TKqpExecuterBase : public TActorBootstrapped<TDerived> {
1756
1760
ExecuterStateSpan.EndError (response.DebugString ());
1757
1761
1758
1762
Request.Transactions .crop (0 );
1759
- this ->Shutdown ();
1763
+ this ->Send (Target, ResponseEv.release ());
1764
+ this ->PassAway ();
1760
1765
}
1761
1766
1762
1767
protected:
@@ -1824,16 +1829,7 @@ class TKqpExecuterBase : public TActorBootstrapped<TDerived> {
1824
1829
}
1825
1830
1826
1831
protected:
1827
- // Introduced separate method from `PassAway()` - to not get confused with expectations from other actors,
1828
- // that `PassAway()` should kill actor immediately.
1829
- virtual void Shutdown () {
1830
- PassAway ();
1831
- }
1832
-
1833
1832
void PassAway () override {
1834
- YQL_ENSURE (AlreadyReplied && ResponseEv);
1835
- this ->Send (Target, ResponseEv.release ());
1836
-
1837
1833
for (auto channelPair: ResultChannelProxies) {
1838
1834
LOG_D (" terminate result channel " << channelPair.first << " proxy at " << channelPair.second ->SelfId ());
1839
1835
@@ -1854,11 +1850,12 @@ class TKqpExecuterBase : public TActorBootstrapped<TDerived> {
1854
1850
1855
1851
if (KqpTableResolverId) {
1856
1852
this ->Send (KqpTableResolverId, new TEvents::TEvPoison);
1853
+ this ->Send (this ->SelfId (), new TEvents::TEvPoison);
1854
+ LOG_T (" Terminate, become ZombieState" );
1855
+ this ->Become (&TKqpExecuterBase::ZombieState);
1856
+ } else {
1857
+ IActor::PassAway ();
1857
1858
}
1858
-
1859
- this ->Send (this ->SelfId (), new TEvents::TEvPoison);
1860
- LOG_T (" Terminate, become ZombieState" );
1861
- this ->Become (&TKqpExecuterBase::ZombieState);
1862
1859
}
1863
1860
1864
1861
STATEFN (ZombieState) {
0 commit comments