Skip to content

Commit 74a9259

Browse files
committed
Add try-catch exception handling for 25.1
1 parent a184bbe commit 74a9259

File tree

1 file changed

+28
-27
lines changed

1 file changed

+28
-27
lines changed

ydb/core/tx/datashard/build_index/recompute_kmeans.cpp

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ using namespace NKMeans;
4040
* - Mean value is calculated for each centroid and returned in the response
4141
*/
4242

43-
class TRecomputeKMeansScan: public TActor<TRecomputeKMeansScan>, public IActorExceptionHandler, public NTable::IScan {
43+
class TRecomputeKMeansScan: public TActor<TRecomputeKMeansScan>, public NTable::IScan {
4444
protected:
4545
const ui64 TabletId = 0;
4646
const ui64 BuildId = 0;
@@ -88,7 +88,7 @@ class TRecomputeKMeansScan: public TActor<TRecomputeKMeansScan>, public IActorEx
8888
Lead.SetTags(ScanTags);
8989
}
9090

91-
TInitialState Prepare(IDriver* driver, TIntrusiveConstPtr<TScheme>) final
91+
TInitialState Prepare(IDriver* driver, TIntrusiveConstPtr<TScheme>) noexcept final
9292
{
9393
TActivationContext::AsActorContext().RegisterWithSameMailbox(this);
9494
LOG_I("Prepare " << Debug());
@@ -98,22 +98,13 @@ class TRecomputeKMeansScan: public TActor<TRecomputeKMeansScan>, public IActorEx
9898
return {EScan::Feed, {}};
9999
}
100100

101-
TAutoPtr<IDestructable> Finish(const std::exception& exc) final
102-
{
103-
Issues.AddIssue(NYql::TIssue(TStringBuilder()
104-
<< "Scan failed " << exc.what()));
105-
return Finish(EStatus::Exception);
106-
}
107-
108-
TAutoPtr<IDestructable> Finish(EStatus status) final
101+
TAutoPtr<IDestructable> Finish(EAbort abort) noexcept final
109102
{
110103
auto& record = Response->Record;
111104
record.SetReadRows(ReadRows);
112105
record.SetReadBytes(ReadBytes);
113106

114-
if (status == EStatus::Exception) {
115-
record.SetStatus(NKikimrIndexBuilder::EBuildStatus::BUILD_ERROR);
116-
} else if (status != NTable::EStatus::Done) {
107+
if (abort != EAbort::None) {
117108
record.SetStatus(NKikimrIndexBuilder::EBuildStatus::ABORTED);
118109
} else {
119110
record.SetStatus(NKikimrIndexBuilder::EBuildStatus::DONE);
@@ -134,31 +125,28 @@ class TRecomputeKMeansScan: public TActor<TRecomputeKMeansScan>, public IActorEx
134125
return nullptr;
135126
}
136127

137-
bool OnUnhandledException(const std::exception& exc) final
138-
{
139-
if (!Driver) {
140-
return false;
141-
}
142-
Driver->Throw(exc);
143-
return true;
144-
}
145-
146-
void Describe(IOutputStream& out) const final
128+
void Describe(IOutputStream& out) const noexcept final
147129
{
148130
out << Debug();
149131
}
150132

151-
EScan Seek(TLead& lead, ui64 seq) final
133+
EScan Seek(TLead& lead, ui64 seq) noexcept final
152134
{
135+
try {
153136
LOG_T("Seek " << seq << " " << Debug());
154137

155138
lead = Lead;
156139

157140
return EScan::Feed;
141+
} catch (const std::exception& exc) {
142+
Issues.AddIssue(exc.what());
143+
return EScan::Final;
144+
}
158145
}
159146

160-
EScan Feed(TArrayRef<const TCell> key, const TRow& row) final
147+
EScan Feed(TArrayRef<const TCell> key, const TRow& row) noexcept final
161148
{
149+
try {
162150
// LOG_T("Feed " << Debug());
163151

164152
++ReadRows;
@@ -167,13 +155,22 @@ class TRecomputeKMeansScan: public TActor<TRecomputeKMeansScan>, public IActorEx
167155
Feed(key, *row);
168156

169157
return EScan::Feed;
158+
} catch (const std::exception& exc) {
159+
Issues.AddIssue(exc.what());
160+
return EScan::Final;
161+
}
170162
}
171163

172-
EScan Exhausted() final
164+
EScan Exhausted() noexcept final
173165
{
166+
try {
174167
LOG_T("Exhausted " << Debug());
175168

176169
return EScan::Final;
170+
} catch (const std::exception& exc) {
171+
Issues.AddIssue(exc.what());
172+
return EScan::Final;
173+
}
177174
}
178175

179176
protected:
@@ -198,8 +195,9 @@ class TRecomputeKMeansScan: public TActor<TRecomputeKMeansScan>, public IActorEx
198195
}
199196
}
200197

201-
void FillResponse()
198+
void FillResponse() noexcept
202199
{
200+
try{
203201
auto& record = Response->Record;
204202
Clusters->RecomputeClusters();
205203
const auto& clusters = Clusters->GetClusters();
@@ -209,6 +207,9 @@ class TRecomputeKMeansScan: public TActor<TRecomputeKMeansScan>, public IActorEx
209207
record.AddClusterSizes(sizes[i]);
210208
}
211209
record.SetStatus(NKikimrIndexBuilder::EBuildStatus::DONE);
210+
} catch (const std::exception& exc) {
211+
Issues.AddIssue(exc.what());
212+
}
212213
}
213214
};
214215

0 commit comments

Comments
 (0)