Skip to content

Revert "Always use EvWrite" #16341

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions ydb/core/kqp/opt/kqp_query_plan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -839,17 +839,15 @@ class TxPlanSerializer {
op.Properties["Table"] = tableData.RelativePath ? *tableData.RelativePath : tablePath;
op.Properties["Path"] = tablePath;

if (writeInfo.Type != EPlanTableWriteType::MultiErase) {
const auto& tupleType = stage.Ref().GetTypeAnn()->Cast<TTupleExprType>();
YQL_ENSURE(tupleType);
YQL_ENSURE(tupleType->GetSize() == 1);
const auto& listType = tupleType->GetItems()[0]->Cast<TListExprType>();
YQL_ENSURE(listType);
const auto& structType = listType->GetItemType()->Cast<TStructExprType>();
YQL_ENSURE(structType);
for (const auto& item : structType->GetItems()) {
writeInfo.Columns.push_back(TString(item->GetName()));
}
const auto& tupleType = stage.Ref().GetTypeAnn()->Cast<TTupleExprType>();
YQL_ENSURE(tupleType);
YQL_ENSURE(tupleType->GetSize() == 1);
const auto& listType = tupleType->GetItems()[0]->Cast<TListExprType>();
YQL_ENSURE(listType);
const auto& structType = listType->GetItemType()->Cast<TStructExprType>();
YQL_ENSURE(structType);
for (const auto& item : structType->GetItems()) {
writeInfo.Columns.push_back(TString(item->GetName()));
}

SerializerCtx.Tables[tablePath].Writes.push_back(writeInfo);
Expand Down
9 changes: 2 additions & 7 deletions ydb/core/kqp/ut/scheme/kqp_scheme_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9981,10 +9981,9 @@ Y_UNIT_TEST_SUITE(KqpScheme) {
);
}

Y_UNIT_TEST_TWIN(DoubleCreateResourcePoolClassifier, UseSink) {
Y_UNIT_TEST(DoubleCreateResourcePoolClassifier) {
NKikimrConfig::TAppConfig config;
config.MutableFeatureFlags()->SetEnableResourcePools(true);
config.MutableTableServiceConfig()->SetEnableOltpSink(UseSink);

TKikimrRunner kikimr(NKqp::TKikimrSettings()
.SetAppConfig(config)
Expand All @@ -10011,11 +10010,7 @@ Y_UNIT_TEST_SUITE(KqpScheme) {
);)";
auto result = session.ExecuteSchemeQuery(query).GetValueSync();
UNIT_ASSERT_VALUES_EQUAL(result.GetStatus(), EStatus::GENERIC_ERROR);
if (UseSink) {
UNIT_ASSERT_STRING_CONTAINS_C(result.GetIssues().ToString(), "Duplicate keys have been found", result.GetIssues().ToString());
} else {
UNIT_ASSERT_STRING_CONTAINS_C(result.GetIssues().ToString(), "Conflict with existing key", result.GetIssues().ToString());
}
UNIT_ASSERT_STRING_CONTAINS_C(result.GetIssues().ToString(), "Conflict with existing key", result.GetIssues().ToString());
}
}

Expand Down
2 changes: 1 addition & 1 deletion ydb/core/protos/table_service_config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ message TTableServiceConfig {
optional uint64 IdxLookupJoinPointsLimit = 58 [default = 3];
reserved 59; //optional bool OldLookupJoinBehaviour = 59 [default = false];

optional bool EnableOltpSink = 60 [default = true];
optional bool EnableOltpSink = 60 [default = false];

enum EBlockChannelsMode {
BLOCK_CHANNELS_SCALAR = 0;
Expand Down
2 changes: 1 addition & 1 deletion ydb/core/tx/datashard/check_write_unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ EExecutionStatus TCheckWriteUnit::Execute(TOperation::TPtr op,
if (!Pipeline.AssignPlanInterval(op)) {
TString err = TStringBuilder() << "Can't propose tx " << op->GetTxId() << " at blocked shard " << DataShard.TabletID();

writeOp->SetError(NKikimrDataEvents::TEvWriteResult::STATUS_OVERLOADED, err);
writeOp->SetError(NKikimrDataEvents::TEvWriteResult::STATUS_INTERNAL_ERROR, err);
op->Abort(EExecutionUnitKind::FinishProposeWrite);

LOG_NOTICE_S(ctx, NKikimrServices::TX_DATASHARD, err);
Expand Down
2 changes: 1 addition & 1 deletion ydb/services/persqueue_v1/ut/topic_service_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ Y_UNIT_TEST_F(MultiplePartitionsAndNoGapsInTheOffsets, TUpdateOffsetsInTransacti
auto result = tx->Commit().ExtractValueSync();
Cerr << ">>> CommitTx >>>" << Endl;
UNIT_ASSERT_EQUAL(result.IsTransportError(), false);
UNIT_ASSERT_VALUES_EQUAL(result.GetStatus(), NYdb::EStatus::BAD_REQUEST);
UNIT_ASSERT_VALUES_EQUAL(result.GetStatus(), NYdb::EStatus::ABORTED);
}

}
Expand Down
27 changes: 19 additions & 8 deletions ydb/services/ydb/ydb_table_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2913,12 +2913,12 @@ R"___(<main>: Error: Transaction not found: , code: 2015
} else {
// Cerr << "\nQUERY: " << query << "\nSTATS:\n" << result.GetStats()->ToString() << Endl;
auto& stats = NYdb::TProtoAccessor::GetProto(*result.GetStats());
UNIT_ASSERT_VALUES_EQUAL(stats.query_phases().size(), 1);
UNIT_ASSERT_VALUES_EQUAL(stats.query_phases(0).table_access().size(), 1);
UNIT_ASSERT_VALUES_EQUAL(stats.query_phases(0).table_access(0).name(), "/Root/Foo");
UNIT_ASSERT_VALUES_EQUAL(stats.query_phases(0).table_access(0).updates().rows(), 2);
UNIT_ASSERT(stats.query_phases(0).table_access(0).updates().bytes() > 1);
UNIT_ASSERT(stats.query_phases(0).cpu_time_us() > 0);
UNIT_ASSERT_VALUES_EQUAL(stats.query_phases().size(), 2);
UNIT_ASSERT_VALUES_EQUAL(stats.query_phases(1).table_access().size(), 1);
UNIT_ASSERT_VALUES_EQUAL(stats.query_phases(1).table_access(0).name(), "/Root/Foo");
UNIT_ASSERT_VALUES_EQUAL(stats.query_phases(1).table_access(0).updates().rows(), 2);
UNIT_ASSERT(stats.query_phases(1).table_access(0).updates().bytes() > 1);
UNIT_ASSERT(stats.query_phases(1).cpu_time_us() > 0);
UNIT_ASSERT(stats.total_duration_us() > 0);
}
}
Expand Down Expand Up @@ -2978,13 +2978,24 @@ R"___(<main>: Error: Transaction not found: , code: 2015
auto& stats = NYdb::TProtoAccessor::GetProto(*result.GetStats());

int idx = 0;
UNIT_ASSERT_VALUES_EQUAL(stats.query_phases().size(), 1);
if (stats.query_phases().size() == 2) {
idx = 0;
} else {
UNIT_ASSERT_VALUES_EQUAL(stats.query_phases().size(), 3);
UNIT_ASSERT(stats.query_phases(0).table_access().empty());
idx = 1;
}

// 1st phase: find matching rows
UNIT_ASSERT_VALUES_EQUAL(stats.query_phases(idx).table_access().size(), 1);
UNIT_ASSERT_VALUES_EQUAL(stats.query_phases(idx).table_access(0).name(), "/Root/Foo");
UNIT_ASSERT_VALUES_EQUAL(stats.query_phases(idx).table_access(0).reads().rows(), 2);
UNIT_ASSERT_VALUES_EQUAL(stats.query_phases(idx).table_access(0).deletes().rows(), 2);
UNIT_ASSERT(stats.query_phases(idx).cpu_time_us() > 0);
// 2nd phase: delete found rows
UNIT_ASSERT_VALUES_EQUAL(stats.query_phases(idx + 1).table_access().size(), 1);
UNIT_ASSERT_VALUES_EQUAL(stats.query_phases(idx + 1).table_access(0).name(), "/Root/Foo");
UNIT_ASSERT_VALUES_EQUAL(stats.query_phases(idx + 1).table_access(0).deletes().rows(), 2);
UNIT_ASSERT(stats.query_phases(idx + 1).cpu_time_us() > 0);
UNIT_ASSERT(stats.total_duration_us() > 0);
}
}
Expand Down
2 changes: 1 addition & 1 deletion ydb/tests/functional/api/test_insert.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def callee():
callee,
raises(
ydb.PreconditionFailed,
"Duplicate keys have been found."
"Conflict with existing key."
)
)

Expand Down
2 changes: 0 additions & 2 deletions ydb/tests/functional/api/test_isolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -650,8 +650,6 @@ def test_anti_dependency_cycles_g2_two_edges(self):

def callee():
t1.execute('{} update {} set value = 0 where id = 1;'.format(prefix, table_name))
# Sinks allow UPDATE statement to be delayed, so we do commit here to execute update.
t1.commit()

assert_that(
callee,
Expand Down
1 change: 0 additions & 1 deletion ydb/tests/functional/api/ya.make
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ FORK_TEST_FILES()
SIZE(MEDIUM)

ENV(YDB_DRIVER_BINARY="ydb/apps/ydbd/ydbd")
ENV(YDB_HARD_MEMORY_LIMIT_BYTES="8000000000")

TEST_SRCS(
test_session_pool.py
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,21 @@
},
{
"name": "/local/base_dynumber_insert_from_table_sql_plan/ResultTableDyNumber",
"reads": [
{
"lookup_by": [
"Key"
],
"type": "Lookup"
}
],
"writes": [
{
"columns": [
"Key",
"Value"
],
"type": "MultiInsert"
"type": "MultiUpsert"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,21 @@
"tables": [
{
"name": "/local/base_dynumber_insert_literal_sql_plan/ResultLiteralDyNumber",
"reads": [
{
"lookup_by": [
"Key"
],
"type": "Lookup"
}
],
"writes": [
{
"columns": [
"Key",
"Value"
],
"type": "MultiInsert"
"type": "MultiUpsert"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,21 @@
"tables": [
{
"name": "/local/base_dynumber_insert_params_sql_plan/ResultParamsDyNumber",
"reads": [
{
"lookup_by": [
"Key"
],
"type": "Lookup"
}
],
"writes": [
{
"columns": [
"Key",
"Value"
],
"type": "MultiInsert"
"type": "MultiUpsert"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -519,23 +519,27 @@
"PlanNodeType": "Query",
"Plans": [
{
"Node Type": "Sink",
"Node Type": "Effect",
"PlanNodeId": 2,
"Plans": [
{
"Node Type": "ConstantExpr-Sink",
"CTE Name": "precompute_0_0",
"Node Type": "Upsert-ConstantExpr",
"Operators": [
{
"Inputs": [],
"Iterator": "[{Key: 3,Value: \"Three\"},{Key: 4,Value: \"Four\"}]",
"Name": "Iterator"
"Inputs": [
{
"InternalOperatorId": 1
}
],
"Name": "Upsert",
"Path": "/local/base_explain_script_script/ScriptingTest",
"Table": "base_explain_script_script/ScriptingTest"
},
{
"Inputs": [],
"Name": "Replace",
"Path": "/local/base_explain_script_script/ScriptingTest",
"SinkType": "KqpTableSink",
"Table": "base_explain_script_script/ScriptingTest"
"Iterator": "precompute_0_0",
"Name": "Iterator"
}
],
"PlanNodeId": 1,
Expand All @@ -559,7 +563,7 @@
"Key",
"Value"
],
"type": "MultiReplace"
"type": "MultiUpsert"
}
]
}
Expand All @@ -571,23 +575,27 @@
"PlanNodeType": "Query",
"Plans": [
{
"Node Type": "Sink",
"Node Type": "Effect",
"PlanNodeId": 2,
"Plans": [
{
"Node Type": "ConstantExpr-Sink",
"CTE Name": "precompute_0_0",
"Node Type": "Upsert-ConstantExpr",
"Operators": [
{
"Inputs": [],
"Iterator": "[{Key: 1,Value: \"One\"},{Key: 2,Value: \"Two\"}]",
"Name": "Iterator"
"Inputs": [
{
"InternalOperatorId": 1
}
],
"Name": "Upsert",
"Path": "/local/base_explain_script_script/ScriptingTest",
"Table": "base_explain_script_script/ScriptingTest"
},
{
"Inputs": [],
"Name": "Replace",
"Path": "/local/base_explain_script_script/ScriptingTest",
"SinkType": "KqpTableSink",
"Table": "base_explain_script_script/ScriptingTest"
"Iterator": "precompute_0_0",
"Name": "Iterator"
}
],
"PlanNodeId": 1,
Expand All @@ -611,7 +619,7 @@
"Key",
"Value"
],
"type": "MultiReplace"
"type": "MultiUpsert"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,23 +294,27 @@
"PlanNodeType": "Query",
"Plans": [
{
"Node Type": "Sink",
"Node Type": "Effect",
"PlanNodeId": 2,
"Plans": [
{
"Node Type": "ConstantExpr-Sink",
"CTE Name": "precompute_0_0",
"Node Type": "Upsert-ConstantExpr",
"Operators": [
{
"Inputs": [],
"Iterator": "[{Group: 1,Value: \"One\"},{Group: 3,Value: \"Three\"}]",
"Name": "Iterator"
"Inputs": [
{
"InternalOperatorId": 1
}
],
"Name": "Upsert",
"Path": "/local/base_join_group_by_lookup_script_script/Temp",
"Table": "base_join_group_by_lookup_script_script/Temp"
},
{
"Inputs": [],
"Name": "Replace",
"Path": "/local/base_join_group_by_lookup_script_script/Temp",
"SinkType": "KqpTableSink",
"Table": "base_join_group_by_lookup_script_script/Temp"
"Iterator": "precompute_0_0",
"Name": "Iterator"
}
],
"PlanNodeId": 1,
Expand All @@ -334,7 +338,7 @@
"Group",
"Value"
],
"type": "MultiReplace"
"type": "MultiUpsert"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,21 @@
},
{
"name": "/local/base_json_insert_from_table_sql_plan/ResultTableJD",
"reads": [
{
"lookup_by": [
"Key"
],
"type": "Lookup"
}
],
"writes": [
{
"columns": [
"Key",
"Value"
],
"type": "MultiInsert"
"type": "MultiUpsert"
}
]
}
Expand Down
Loading
Loading