Skip to content

Commit 26e567f

Browse files
authored
Fixed Column Shard write stats (ydb-platform#24736)
1 parent cda2755 commit 26e567f

File tree

5 files changed

+22
-8
lines changed

5 files changed

+22
-8
lines changed

.github/config/muted_ya.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ ydb/core/kqp/ut/olap KqpOlapSysView.StatsSysViewTable
4646
ydb/core/kqp/ut/opt KqpKv.ReadRows_TimeoutCancelsReads
4747
ydb/core/kqp/ut/query KqpAnalyze.AnalyzeTable+ColumnStore
4848
ydb/core/kqp/ut/query KqpLimits.ComputeNodeMemoryLimit
49-
ydb/core/kqp/ut/query KqpStats.CreateTableAsStats+IsOlap
5049
ydb/core/kqp/ut/query KqpStats.DeferredEffects+UseSink
5150
ydb/core/kqp/ut/scan KqpFlowControl.FlowControl_Unlimited
5251
ydb/core/kqp/ut/scan KqpScan.StreamExecuteScanQueryClientTimeoutBruteForce

ydb/core/kqp/ut/query/kqp_stats_ut.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -915,11 +915,21 @@ Y_UNIT_TEST_TWIN(CreateTableAsStats, IsOlap) {
915915
auto stats = NYdb::TProtoAccessor::GetProto(*result.GetStats());
916916
Cerr << stats.DebugString() << Endl;
917917
UNIT_ASSERT_VALUES_EQUAL(stats.query_phases(0).table_access(0).updates().rows(), 2);
918-
UNIT_ASSERT_VALUES_EQUAL(stats.query_phases(0).table_access(0).updates().bytes(), 24);
919-
UNIT_ASSERT_VALUES_EQUAL(stats.query_phases(0).table_access(0).partitions_count(), 1);
920918
UNIT_ASSERT_VALUES_EQUAL(stats.query_phases(0).table_access(1).reads().rows(), 2);
921-
UNIT_ASSERT_VALUES_EQUAL(stats.query_phases(0).table_access(1).reads().bytes(), 24);
922-
UNIT_ASSERT_VALUES_EQUAL(stats.query_phases(0).table_access(1).partitions_count(), 1);
919+
920+
if (IsOlap) {
921+
// size of serialized may be a little different (because of arrow)
922+
UNIT_ASSERT_GE(stats.query_phases(0).table_access(0).updates().bytes(), 400);
923+
UNIT_ASSERT_LE(stats.query_phases(0).table_access(0).updates().bytes(), 500);
924+
UNIT_ASSERT_VALUES_EQUAL(stats.query_phases(0).table_access(1).reads().bytes(), 40);
925+
UNIT_ASSERT_VALUES_EQUAL(stats.query_phases(0).table_access(0).partitions_count(), 2);
926+
UNIT_ASSERT_VALUES_EQUAL(stats.query_phases(0).table_access(1).partitions_count(), 0);
927+
} else {
928+
UNIT_ASSERT_VALUES_EQUAL(stats.query_phases(0).table_access(0).updates().bytes(), 24);
929+
UNIT_ASSERT_VALUES_EQUAL(stats.query_phases(0).table_access(1).reads().bytes(), 24);
930+
UNIT_ASSERT_VALUES_EQUAL(stats.query_phases(0).table_access(0).partitions_count(), 1);
931+
UNIT_ASSERT_VALUES_EQUAL(stats.query_phases(0).table_access(1).partitions_count(), 1);
932+
}
923933
}
924934

925935
{

ydb/core/tx/columnshard/blobs_action/common/statistics.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@
33
namespace NKikimr::NColumnShard {
44

55
void AddTableAccessStatsToTxStats(NKikimrQueryStats::TTxStats& stats, ui64 pathId, ui64 rows, ui64 bytes,
6-
NEvWrite::EModificationType modificationType) {
6+
NEvWrite::EModificationType modificationType, ui64 shardId) {
77
auto tableStats = stats.AddTableAccessStats();
88
tableStats->MutableTableInfo()->SetPathId(pathId);
99
auto row = modificationType == NEvWrite::EModificationType::Delete ? tableStats->MutableEraseRow()
1010
: tableStats->MutableUpdateRow();
1111
row->SetCount(rows);
1212
row->SetRows(rows);
1313
row->SetBytes(bytes);
14+
15+
auto shardStats = stats.AddPerShardStats();
16+
shardStats->SetShardId(shardId);
1417
}
1518

1619
} // namespace NKikimr::NColumnShard

ydb/core/tx/columnshard/blobs_action/common/statistics.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
namespace NKikimr::NColumnShard {
88

99
void AddTableAccessStatsToTxStats(NKikimrQueryStats::TTxStats& stats, ui64 pathId, ui64 rows, ui64 bytes,
10-
NEvWrite::EModificationType modificationType);
10+
NEvWrite::EModificationType modificationType, ui64 shardId);
1111

1212
} // namespace NKikimr::NColumnShard

ydb/core/tx/columnshard/blobs_action/transaction/tx_blobs_written.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ bool TTxBlobsWritingFinished::DoExecute(TTransactionContext& txc, const TActorCo
7272
if (operation->GetBehaviour() == EOperationBehaviour::NoTxWrite) {
7373
LWPROBE(EvWriteResult, Self->TabletID(), writeMeta.GetSource().ToString(), 0, operation->GetCookie(), "no_tx_write", true, "");
7474
auto ev = NEvents::TDataEvents::TEvWriteResult::BuildCompleted(Self->TabletID());
75+
AddTableAccessStatsToTxStats(*ev->Record.MutableTxStats(), writeMeta.GetPathId().SchemeShardLocalPathId.GetRawValue(),
76+
writeResult.GetRecordsCount(), writeResult.GetDataSize(), operation->GetModificationType(), Self->TabletID());
7577
Results.emplace_back(std::move(ev), writeMeta.GetSource(), operation->GetCookie());
7678
} else {
7779
auto& info = Self->OperationsManager->GetLockVerified(operation->GetLockId());
@@ -84,7 +86,7 @@ bool TTxBlobsWritingFinished::DoExecute(TTransactionContext& txc, const TActorCo
8486
LWPROBE(EvWriteResult, Self->TabletID(), writeMeta.GetSource().ToString(), 0, operation->GetCookie(), "tx_write", true, "");
8587
auto ev = NEvents::TDataEvents::TEvWriteResult::BuildCompleted(Self->TabletID(), operation->GetLockId(), lock);
8688
AddTableAccessStatsToTxStats(*ev->Record.MutableTxStats(), writeMeta.GetPathId().SchemeShardLocalPathId.GetRawValue(),
87-
writeResult.GetRecordsCount(), writeResult.GetDataSize(), operation->GetModificationType());
89+
writeResult.GetRecordsCount(), writeResult.GetDataSize(), operation->GetModificationType(), Self->TabletID());
8890
Results.emplace_back(std::move(ev), writeMeta.GetSource(), operation->GetCookie());
8991
}
9092
}

0 commit comments

Comments
 (0)