File tree Expand file tree Collapse file tree 2 files changed +28
-3
lines changed
qplayer/storage/interface Expand file tree Collapse file tree 2 files changed +28
-3
lines changed Original file line number Diff line number Diff line change 1
1
#include " yql_qstorage.h"
2
2
3
+ #include < util/system/mutex.h>
4
+
3
5
namespace NYql {
4
6
class TQWriterDecorator : public IQWriter {
5
7
public:
@@ -8,14 +10,31 @@ class TQWriterDecorator : public IQWriter {
8
10
if (Closed_) {
9
11
return NThreading::MakeFuture ();
10
12
}
11
- return Underlying_->Put (key, value);
13
+ try {
14
+ return Underlying_->Put (key, value);
15
+ } catch (...) {
16
+ auto message = CurrentExceptionMessage ();
17
+ with_lock (Mutex_) {
18
+ Exception_ = std::move (message);
19
+ }
20
+ Close ();
21
+ return NThreading::MakeFuture ();
22
+ }
12
23
}
13
24
14
25
NThreading::TFuture<void > Commit () override final {
15
- if (Closed_) {
26
+ with_lock (Mutex_) {
27
+ if (Exception_) {
28
+ throw yexception () << " QWriter exception while Put(): " << *Exception_ << " )" ;
29
+ }
30
+ }
31
+ bool expected = false ;
32
+ if (!Closed_.compare_exchange_strong (expected, true )) {
16
33
throw yexception () << " QWriter closed" ;
17
34
}
18
- return Underlying_->Commit ();
35
+ auto result = Underlying_->Commit ();
36
+ Underlying_ = {};
37
+ return result;
19
38
}
20
39
21
40
// Close all used files, doesn't commit anything
@@ -26,8 +45,10 @@ class TQWriterDecorator : public IQWriter {
26
45
}
27
46
}
28
47
private:
48
+ TMaybe<TString> Exception_;
29
49
IQWriterPtr Underlying_;
30
50
std::atomic<bool > Closed_ = false ;
51
+ TMutex Mutex_;
31
52
};
32
53
33
54
IQWriterPtr MakeCloseAwareWriterDecorator (IQWriterPtr&& rhs) {
Original file line number Diff line number Diff line change 37
37
#include <util/string/cast.h>
38
38
#include <util/string/join.h>
39
39
#include <util/string/split.h>
40
+ #include <util/system/env.h>
40
41
41
42
#include <algorithm>
42
43
#include <functional>
@@ -589,12 +590,15 @@ namespace NTypeAnnImpl {
589
590
}
590
591
591
592
auto failureKind = input->Child(0)->Content();
593
+ Y_ABORT_UNLESS(!TryGetEnv("YQL_DETERMINISTIC_MODE") || failureKind != "crash");
592
594
if (failureKind == "expr") {
593
595
input->SetTypeAnn(ctx.Expr.MakeType<TDataExprType>(NUdf::EDataSlot::String));
594
596
} else if (failureKind == "type") {
595
597
input->SetTypeAnn(ctx.Expr.MakeType<TDataExprType>(NUdf::EDataSlot::String));
596
598
} else if (failureKind == "constraint") {
597
599
input->SetTypeAnn(ctx.Expr.MakeType<TListExprType>(ctx.Expr.MakeType<TDataExprType>(NUdf::EDataSlot::String)));
600
+ } else if (failureKind == "exception") {
601
+ ythrow yexception() << "FailMe exception";
598
602
} else {
599
603
ctx.Expr.AddError(TIssue(ctx.Expr.GetPosition(input->Child(0)->Pos()), TStringBuilder() << "Unknown failure kind: " << failureKind));
600
604
return IGraphTransformer::TStatus::Error;
You can’t perform that action at this time.
0 commit comments