summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorudovichenko-r <[email protected]>2025-01-30 22:38:53 +0300
committerudovichenko-r <[email protected]>2025-01-30 23:33:19 +0300
commit510c36818ff4f9a5a4469aa478cb01f52aa6fbd5 (patch)
tree2088d138b78c27f7b32559e3f500606b3d1a5401
parent5677d72d8eb0324ca964ec09319d086857a01003 (diff)
Freeze a job in case of abnormal situation
commit_hash:2a18627ec456d66b242b732bd639e0a3acbad54b
-rw-r--r--yt/yql/providers/yt/comp_nodes/ya.make.inc1
-rw-r--r--yt/yql/providers/yt/comp_nodes/yql_mkql_file_list.cpp7
-rw-r--r--yt/yql/providers/yt/lib/errors/ya.make12
-rw-r--r--yt/yql/providers/yt/lib/errors/yql_emergency_sleep.cpp33
-rw-r--r--yt/yql/providers/yt/lib/errors/yql_emergency_sleep.h24
5 files changed, 75 insertions, 2 deletions
diff --git a/yt/yql/providers/yt/comp_nodes/ya.make.inc b/yt/yql/providers/yt/comp_nodes/ya.make.inc
index b0a54d85a4a..10dd6dcaacf 100644
--- a/yt/yql/providers/yt/comp_nodes/ya.make.inc
+++ b/yt/yql/providers/yt/comp_nodes/ya.make.inc
@@ -23,6 +23,7 @@ PEERDIR(
yql/essentials/providers/common/mkql
yt/yql/providers/yt/codec
yt/yql/providers/yt/expr_nodes
+ yt/yql/providers/yt/lib/errors
)
YQL_LAST_ABI_VERSION()
diff --git a/yt/yql/providers/yt/comp_nodes/yql_mkql_file_list.cpp b/yt/yql/providers/yt/comp_nodes/yql_mkql_file_list.cpp
index 7d720cbbd5d..dcfff4ba030 100644
--- a/yt/yql/providers/yt/comp_nodes/yql_mkql_file_list.cpp
+++ b/yt/yql/providers/yt/comp_nodes/yql_mkql_file_list.cpp
@@ -1,6 +1,9 @@
#include "yql_mkql_file_list.h"
#include "yql_mkql_file_input_state.h"
+#include <yt/yql/providers/yt/lib/errors/yql_emergency_sleep.h>
+
+
namespace NYql {
using namespace NKikimr::NMiniKQL;
@@ -18,12 +21,12 @@ bool TFileListValueBase::TIterator::Next(NUdf::TUnboxedValue& value) {
}
AtStart_ = false;
if (!State_->IsValid()) {
- MKQL_ENSURE(!ExpectedLength_ || *ExpectedLength_ == 0, "Invalid file length, ExpectedLength=" << *ExpectedLength_ << ", State: " << State_->DebugInfo());
+ YQL_EMERGENCY_SLEEP(!ExpectedLength_ || *ExpectedLength_ == 0, "Invalid file length, ExpectedLength=" << *ExpectedLength_ << ", State: " << State_->DebugInfo());
return false;
}
if (ExpectedLength_) {
- MKQL_ENSURE(*ExpectedLength_ > 0, "Invalid file length. State: " << State_->DebugInfo());
+ YQL_EMERGENCY_SLEEP(*ExpectedLength_ > 0, "Invalid file length. State: " << State_->DebugInfo());
--(*ExpectedLength_);
}
value = State_->GetCurrent();
diff --git a/yt/yql/providers/yt/lib/errors/ya.make b/yt/yql/providers/yt/lib/errors/ya.make
new file mode 100644
index 00000000000..4f111f24cb0
--- /dev/null
+++ b/yt/yql/providers/yt/lib/errors/ya.make
@@ -0,0 +1,12 @@
+LIBRARY()
+
+SRCS(
+ yql_emergency_sleep.cpp
+ yql_emergency_sleep.h
+)
+
+PEERDIR(
+ yql/essentials/utils
+)
+
+END()
diff --git a/yt/yql/providers/yt/lib/errors/yql_emergency_sleep.cpp b/yt/yql/providers/yt/lib/errors/yql_emergency_sleep.cpp
new file mode 100644
index 00000000000..867191f6e3d
--- /dev/null
+++ b/yt/yql/providers/yt/lib/errors/yql_emergency_sleep.cpp
@@ -0,0 +1,33 @@
+#include "yql_emergency_sleep.h"
+
+#include <util/system/env.h>
+#include <util/stream/output.h>
+#include <util/datetime/base.h>
+
+
+namespace NYql::NPrivate {
+
+namespace {
+
+struct TIsInsideJob {
+ TIsInsideJob()
+ : InsideJob(!GetEnv("YT_JOB_ID").empty())
+ {
+ }
+ const bool InsideJob;
+};
+
+} // unnamed
+
+bool IsInsideJob() {
+ return Singleton<TIsInsideJob>()->InsideJob;
+}
+
+void ReportAndSleep(const TString& msg) {
+ Cerr << "An abnormal situation found, so consider opening a bug report to YQL (st/YQLSUPPORT)" << Endl << msg << Endl;
+ while (true) {
+ ::Sleep(TDuration::Seconds(5));
+ }
+}
+
+} // NYql::NPrivate
diff --git a/yt/yql/providers/yt/lib/errors/yql_emergency_sleep.h b/yt/yql/providers/yt/lib/errors/yql_emergency_sleep.h
new file mode 100644
index 00000000000..34113849e87
--- /dev/null
+++ b/yt/yql/providers/yt/lib/errors/yql_emergency_sleep.h
@@ -0,0 +1,24 @@
+#pragma once
+
+#include <yql/essentials/utils/yql_panic.h>
+#include <util/generic/string.h>
+#include <util/string/builder.h>
+
+
+namespace NYql {
+
+namespace NPrivate {
+
+bool IsInsideJob();
+void ReportAndSleep(const TString& msg);
+
+} // NPrivate
+
+#define YQL_EMERGENCY_SLEEP(condition, ...) \
+ if (!NYql::NPrivate::IsInsideJob()) { \
+ YQL_ENSURE(condition, __VA_ARGS__); \
+ } else if (Y_UNLIKELY(!(condition))) { \
+ NYql::NPrivate::ReportAndSleep(TStringBuilder() << #condition << ", " __VA_ARGS__); \
+ }
+
+} // namespace NYql