@@ -7405,7 +7405,7 @@ void TSchemeShard::Handle(TEvTxProxySchemeCache::TEvNavigateKeySetResult::TPtr&
74057405 StatisticsAggregatorId = TTabletId (entry.DomainInfo ->Params .GetStatisticsAggregator ());
74067406 LOG_DEBUG_S (TlsActivationContext->AsActorContext (), NKikimrServices::STATISTICS,
74077407 " Handle TEvTxProxySchemeCache::TEvNavigateKeySetResult, StatisticsAggregatorId=" << StatisticsAggregatorId
7408- << " , at schemeshard: " << TabletID ());
7408+ << " , at schemeshard: " << TabletID ());
74097409 ConnectToSA ();
74107410 }
74117411}
@@ -7414,13 +7414,16 @@ void TSchemeShard::Handle(TEvPrivate::TEvSendBaseStatsToSA::TPtr&, const TActorC
74147414 TDuration delta = SendBaseStatsToSA ();
74157415 LOG_DEBUG_S (TlsActivationContext->AsActorContext (), NKikimrServices::STATISTICS,
74167416 " Schedule next SendBaseStatsToSA in " << delta
7417- << " , at schemeshard: " << TabletID ());
7417+ << " , at schemeshard: " << TabletID ());
74187418 ctx.Schedule (delta, new TEvPrivate::TEvSendBaseStatsToSA ());
74197419}
74207420
74217421void TSchemeShard::InitializeStatistics (const TActorContext& ctx) {
74227422 ResolveSA ();
7423- ctx.Schedule (TDuration::Seconds (30 ), new TEvPrivate::TEvSendBaseStatsToSA ());
7423+ // since columnshard statistics is now sent once in a minute,
7424+ // we expect that in most cases we will gather full stats
7425+ // before sending them to StatisticsAggregator
7426+ ctx.Schedule (TDuration::Seconds (120 ), new TEvPrivate::TEvSendBaseStatsToSA ());
74247427}
74257428
74267429void TSchemeShard::ResolveSA () {
@@ -7494,30 +7497,56 @@ TDuration TSchemeShard::SendBaseStatsToSA() {
74947497 }
74957498
74967499 int count = 0 ;
7500+ bool areAllStatsFull = true ;
74977501
74987502 NKikimrStat::TSchemeShardStats record;
74997503 for (const auto & [pathId, tableInfo] : Tables) {
7500- const auto & aggregated = tableInfo->GetStats ().Aggregated ;
7504+ const auto & stats = tableInfo->GetStats ();
7505+ const auto & aggregated = stats.Aggregated ;
7506+ bool areStatsFull = stats.AreStatsFull ();
7507+
75017508 auto * entry = record.AddEntries ();
75027509 auto * entryPathId = entry->MutablePathId ();
75037510 entryPathId->SetOwnerId (pathId.OwnerId );
75047511 entryPathId->SetLocalId (pathId.LocalPathId );
7505- entry->SetRowCount (aggregated.RowCount );
7506- entry->SetBytesSize (aggregated.DataSize );
7512+ entry->SetRowCount (areStatsFull ? aggregated.RowCount : 0 );
7513+ entry->SetBytesSize (areStatsFull ? aggregated.DataSize : 0 );
75077514 entry->SetIsColumnTable (false );
7515+ entry->SetAreStatsFull (areStatsFull);
7516+ areAllStatsFull = areAllStatsFull && areStatsFull;
7517+
75087518 ++count;
75097519 }
7520+
75107521 auto columnTablesPathIds = ColumnTables.GetAllPathIds ();
75117522 for (const auto & pathId : columnTablesPathIds) {
75127523 const auto & tableInfo = ColumnTables.GetVerified (pathId);
7513- const auto & aggregated = tableInfo->Stats .Aggregated ;
7524+ const auto & stats = tableInfo->GetStats ();
7525+ const TTableAggregatedStats* aggregatedStats = nullptr ;
7526+
7527+ // stats are stored differently for standalone and non-standalone column tables
7528+ if (tableInfo->IsStandalone ()) {
7529+ aggregatedStats = &stats;
7530+ } else {
7531+ auto it = stats.TableStats .find (pathId);
7532+ if (it == stats.TableStats .end ()) {
7533+ continue ;
7534+ }
7535+ aggregatedStats = &it->second ;
7536+ }
7537+ const auto & aggregated = aggregatedStats->Aggregated ;
7538+ bool areStatsFull = aggregatedStats->AreStatsFull ();
7539+
75147540 auto * entry = record.AddEntries ();
75157541 auto * entryPathId = entry->MutablePathId ();
75167542 entryPathId->SetOwnerId (pathId.OwnerId );
75177543 entryPathId->SetLocalId (pathId.LocalPathId );
7518- entry->SetRowCount (aggregated.RowCount );
7519- entry->SetBytesSize (aggregated.DataSize );
7544+ entry->SetRowCount (areStatsFull ? aggregated.RowCount : 0 );
7545+ entry->SetBytesSize (areStatsFull ? aggregated.DataSize : 0 );
75207546 entry->SetIsColumnTable (true );
7547+ entry->SetAreStatsFull (areStatsFull);
7548+ areAllStatsFull = areAllStatsFull && areStatsFull;
7549+
75217550 ++count;
75227551 }
75237552
@@ -7528,8 +7557,9 @@ TDuration TSchemeShard::SendBaseStatsToSA() {
75287557 return TDuration::Seconds (30 );
75297558 }
75307559
7560+ record.SetAreAllStatsFull (areAllStatsFull);
7561+
75317562 TString stats;
7532- stats.clear ();
75337563 Y_PROTOBUF_SUPPRESS_NODISCARD record.SerializeToString (&stats);
75347564
75357565 auto event = std::make_unique<NStat::TEvStatistics::TEvSchemeShardStats>();
0 commit comments