Skip to content

Commit aed1c30

Browse files
authored
Do not rewrite SCHEME_ERROR ststus from scheme executor (#2833)
1 parent e91747e commit aed1c30

File tree

7 files changed

+44
-11
lines changed

7 files changed

+44
-11
lines changed

ydb/core/kqp/executer_actor/kqp_executer.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,16 @@ struct TEvKqpExecuter {
3030
ui64 ResultRowsCount = 0;
3131
ui64 ResultRowsBytes = 0;
3232

33-
explicit TEvTxResponse(TTxAllocatorState::TPtr allocState)
33+
enum class EExecutionType {
34+
Data,
35+
Scan,
36+
Scheme,
37+
Literal,
38+
} ExecutionType;
39+
40+
TEvTxResponse(TTxAllocatorState::TPtr allocState, EExecutionType type)
3441
: AllocState(std::move(allocState))
42+
, ExecutionType(type)
3543
{}
3644

3745
~TEvTxResponse();

ydb/core/kqp/executer_actor/kqp_executer_impl.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,7 @@ namespace NKqp {
6464
#define LOG_E(stream) LOG_ERROR_S(*TlsActivationContext, NKikimrServices::KQP_EXECUTER, "ActorId: " << SelfId() << " TxId: " << TxId << ". " << "Ctx: " << *GetUserRequestContext() << ". " << stream)
6565
#define LOG_C(stream) LOG_CRIT_S(*TlsActivationContext, NKikimrServices::KQP_EXECUTER, "ActorId: " << SelfId() << " TxId: " << TxId << ". " << "Ctx: " << *GetUserRequestContext() << ". " << stream)
6666

67-
enum class EExecType {
68-
Data,
69-
Scan
70-
};
67+
using EExecType = TEvKqpExecuter::TEvTxResponse::EExecutionType;
7168

7269
const ui64 MaxTaskSize = 48_MB;
7370

@@ -114,6 +111,7 @@ struct TEvPrivate {
114111

115112
template <class TDerived, EExecType ExecType>
116113
class TKqpExecuterBase : public TActorBootstrapped<TDerived> {
114+
static_assert(ExecType == EExecType::Data || ExecType == EExecType::Scan);
117115
public:
118116
TKqpExecuterBase(IKqpGateway::TExecPhysicalRequest&& request, const TString& database,
119117
const TIntrusiveConstPtr<NACLib::TUserToken>& userToken,
@@ -141,7 +139,7 @@ class TKqpExecuterBase : public TActorBootstrapped<TDerived> {
141139
TasksGraph.GetMeta().Database = Database;
142140
TasksGraph.GetMeta().ChannelTransportVersion = chanTransportVersion;
143141
TasksGraph.GetMeta().UserRequestContext = userRequestContext;
144-
ResponseEv = std::make_unique<TEvKqpExecuter::TEvTxResponse>(Request.TxAlloc);
142+
ResponseEv = std::make_unique<TEvKqpExecuter::TEvTxResponse>(Request.TxAlloc, ExecType);
145143
ResponseEv->Orbit = std::move(Request.Orbit);
146144
Stats = std::make_unique<TQueryExecutionStats>(Request.StatsMode, &TasksGraph,
147145
ResponseEv->Record.MutableResponse()->MutableResult()->MutableStats());

ydb/core/kqp/executer_actor/kqp_literal_executer.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ class TKqpLiteralExecuter {
7979
, LiteralExecuterSpan(TWilsonKqp::LiteralExecuter, std::move(Request.TraceId), "LiteralExecuter")
8080
, UserRequestContext(userRequestContext)
8181
{
82-
ResponseEv = std::make_unique<TEvKqpExecuter::TEvTxResponse>(Request.TxAlloc);
82+
ResponseEv = std::make_unique<TEvKqpExecuter::TEvTxResponse>(
83+
Request.TxAlloc, TEvKqpExecuter::TEvTxResponse::EExecutionType::Literal);
84+
8385
ResponseEv->Orbit = std::move(Request.Orbit);
8486
Stats = std::make_unique<TQueryExecutionStats>(Request.StatsMode, &TasksGraph,
8587
ResponseEv->Record.MutableResponse()->MutableResult()->MutableStats());

ydb/core/kqp/executer_actor/kqp_scheme_executer.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ class TKqpSchemeExecuter : public TActorBootstrapped<TKqpSchemeExecuter> {
6969
YQL_ENSURE(PhyTx);
7070
YQL_ENSURE(PhyTx->GetType() == NKqpProto::TKqpPhyTx::TYPE_SCHEME);
7171

72-
ResponseEv = std::make_unique<TEvKqpExecuter::TEvTxResponse>(nullptr);
72+
ResponseEv = std::make_unique<TEvKqpExecuter::TEvTxResponse>(
73+
nullptr,
74+
TEvKqpExecuter::TEvTxResponse::EExecutionType::Scheme);
7375
}
7476

7577
void StartBuildOperation() {

ydb/core/kqp/executer_actor/ya.make

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ PEERDIR(
4444
ydb/library/yql/providers/common/http_gateway
4545
)
4646

47+
GENERATE_ENUM_SERIALIZATION(
48+
kqp_executer.h
49+
)
50+
4751
YQL_LAST_ABI_VERSION()
4852

4953
END()

ydb/core/kqp/session_actor/kqp_session_actor.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,7 +1336,10 @@ class TKqpSessionActor : public TActorBootstrapped<TKqpSessionActor> {
13361336
ExecuterId = TActorId{};
13371337

13381338
if (response->GetStatus() != Ydb::StatusIds::SUCCESS) {
1339-
LOG_D("TEvTxResponse has non-success status, CurrentTx: " << QueryState->CurrentTx);
1339+
const auto executionType = ev->ExecutionType;
1340+
1341+
LOG_D("TEvTxResponse has non-success status, CurrentTx: " << QueryState->CurrentTx
1342+
<< " ExecutionType: " << executionType);
13401343

13411344
auto status = response->GetStatus();
13421345
TIssues issues;
@@ -1348,11 +1351,14 @@ class TKqpSessionActor : public TActorBootstrapped<TKqpSessionActor> {
13481351
case Ydb::StatusIds::INTERNAL_ERROR:
13491352
InvalidateQuery();
13501353
issues.AddIssue(YqlIssue(TPosition(), TIssuesIds::KIKIMR_QUERY_INVALIDATED,
1351-
TStringBuilder() << "Query invalidated on scheme/internal error."));
1354+
TStringBuilder() << "Query invalidated on scheme/internal error during "
1355+
<< executionType << " execution"));
13521356

13531357
// SCHEME_ERROR during execution is a soft (retriable) error, we abort query execution,
13541358
// invalidate query cache, and return ABORTED as retriable status.
1355-
if (status == Ydb::StatusIds::SCHEME_ERROR) {
1359+
if (status == Ydb::StatusIds::SCHEME_ERROR &&
1360+
executionType != TEvKqpExecuter::TEvTxResponse::EExecutionType::Scheme)
1361+
{
13561362
status = Ydb::StatusIds::ABORTED;
13571363
}
13581364

ydb/core/kqp/ut/service/kqp_qs_queries_ut.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,19 @@ Y_UNIT_TEST_SUITE(KqpQueryService) {
372372
}
373373
}
374374

375+
Y_UNIT_TEST(ExecuteDDLStatusCodeSchemeError) {
376+
TKikimrRunner kikimr(NKqp::TKikimrSettings().SetWithSampleTables(false));
377+
{
378+
auto db = kikimr.GetQueryClient();
379+
auto result = db.ExecuteQuery(R"(
380+
CREATE TABLE unsupported_TzTimestamp (key Int32, payload TzTimestamp, primary key(key)))",
381+
TTxControl::NoTx()
382+
).GetValueSync();
383+
384+
UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::SCHEME_ERROR, result.GetIssues().ToString());
385+
}
386+
}
387+
375388
Y_UNIT_TEST(ExecuteQueryScalar) {
376389
auto kikimr = DefaultKikimrRunner();
377390
auto db = kikimr.GetQueryClient();

0 commit comments

Comments
 (0)