summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorijon <[email protected]>2023-04-14 18:45:18 +0300
committerijon <[email protected]>2023-04-14 18:45:18 +0300
commit54a1101ec4016353864a87ca24d4e97fa58b747d (patch)
treedad977695c2b363034b9965d10610b040965fbbe
parentdbb79b916613029280edbdff9ed14a9a466c52da (diff)
datashard: fix periodic stats sending after reboot during table move
Result of stats building is bound to table id, but move-table changes table id, so moved table with new table-id should start build stats afresh.
-rw-r--r--ydb/core/tx/datashard/datashard.cpp6
-rw-r--r--ydb/core/tx/datashard/datashard__stats.cpp6
-rw-r--r--ydb/core/tx/datashard/datashard_impl.h8
3 files changed, 17 insertions, 3 deletions
diff --git a/ydb/core/tx/datashard/datashard.cpp b/ydb/core/tx/datashard/datashard.cpp
index 3f1c5fab01e..66238089b6f 100644
--- a/ydb/core/tx/datashard/datashard.cpp
+++ b/ydb/core/tx/datashard/datashard.cpp
@@ -1471,6 +1471,12 @@ TUserTable::TPtr TDataShard::MoveUserTable(TOperation::TPtr op, const NKikimrTxD
newTableInfo->SetSchema(schema);
Y_VERIFY(move.ReMapIndexesSize() == newTableInfo->Indexes.size());
+ //NOTE: Stats building is bound to table id, but move-table changes table id,
+ // so already built stats couldn't be inherited by moved table
+ // and have to be rebuilt from the ground up
+ newTableInfo->StatsUpdateInProgress = false;
+ newTableInfo->StatsNeedUpdate = true;
+
RemoveUserTable(prevId);
AddUserTable(newId, newTableInfo);
diff --git a/ydb/core/tx/datashard/datashard__stats.cpp b/ydb/core/tx/datashard/datashard__stats.cpp
index 2df88cfe887..b1e3b94fc3e 100644
--- a/ydb/core/tx/datashard/datashard__stats.cpp
+++ b/ydb/core/tx/datashard/datashard__stats.cpp
@@ -229,7 +229,7 @@ void TDataShard::Handle(TEvPrivate::TEvAsyncTableStats::TPtr& ev, const TActorCo
Actors.erase(ev->Sender);
ui64 tableId = ev->Get()->TableId;
- LOG_DEBUG(ctx, NKikimrServices::TX_DATASHARD, "Stats rebuilt at datashard %" PRIu64, TabletID());
+ LOG_DEBUG_S(ctx, NKikimrServices::TX_DATASHARD, "Stats rebuilt at datashard " << TabletID() << ", for tableId " << tableId);
i64 dataSize = 0;
if (TableInfos.contains(tableId)) {
@@ -253,6 +253,10 @@ void TDataShard::Handle(TEvPrivate::TEvAsyncTableStats::TPtr& ev, const TActorCo
tableInfo.StatsUpdateInProgress = false;
SendPeriodicTableStats(ctx);
+
+ } else {
+ LOG_DEBUG_S(ctx, NKikimrServices::TX_DATASHARD, "Drop stats at datashard " << TabletID()
+ << ", built for tableId " << tableId << ", but table is gone (moved ot dropped)");
}
if (dataSize > HighDataSizeReportThreshlodBytes) {
diff --git a/ydb/core/tx/datashard/datashard_impl.h b/ydb/core/tx/datashard/datashard_impl.h
index 27168c0746c..a78891a0b33 100644
--- a/ydb/core/tx/datashard/datashard_impl.h
+++ b/ydb/core/tx/datashard/datashard_impl.h
@@ -2923,8 +2923,12 @@ protected:
const TUserTable &ti = *t.second;
// Don't report stats until they are build for the first time
- if (!ti.Stats.StatsUpdateTime)
- break;
+ if (!ti.Stats.StatsUpdateTime) {
+ LOG_DEBUG_S(ctx, NKikimrServices::TX_DATASHARD, "SendPeriodicTableStats at datashard " << TabletID()
+ << ", for tableId " << tableId << ", but no stats yet"
+ );
+ continue;
+ }
if (!DbStatsReportPipe) {
NTabletPipe::TClientConfig clientConfig;