@@ -74,7 +74,7 @@ TColumnShard::TColumnShard(TTabletStorageInfo* info, const TActorId& tablet)
7474 , TabletCountersHolder(new TProtobufTabletCounters<ESimpleCounters_descriptor, ECumulativeCounters_descriptor,
7575 EPercentileCounters_descriptor, ETxTypes_descriptor>())
7676 , Counters(*TabletCountersHolder)
77- , InFlightReadsTracker(StoragesManager)
77+ , InFlightReadsTracker(StoragesManager, Counters.GetRequestsTracingCounters() )
7878 , TablesManager(StoragesManager, info->TabletID)
7979 , Subscribers(std::make_shared<NSubscriber::TManager>(*this ))
8080 , PipeClientCache(NTabletPipe::CreateBoundedClientCache(new NTabletPipe::TBoundedClientCacheConfig(), GetPipeClientConfig()))
@@ -84,8 +84,7 @@ TColumnShard::TColumnShard(TTabletStorageInfo* info, const TActorId& tablet)
8484 , TTLTaskSubscription(NOlap::TTTLColumnEngineChanges::StaticTypeName(), Counters.GetSubscribeCounters())
8585 , BackgroundController(Counters.GetBackgroundControllerCounters())
8686 , NormalizerController(StoragesManager, Counters.GetSubscribeCounters())
87- , SysLocks(this )
88- , MaxReadStaleness(TDuration::MilliSeconds(AppDataVerified().ColumnShardConfig.GetMaxReadStaleness_ms())) {
87+ , SysLocks(this ) {
8988}
9089
9190void TColumnShard::OnDetach (const TActorContext& ctx) {
@@ -186,12 +185,18 @@ ui64 TColumnShard::GetOutdatedStep() const {
186185 return step;
187186}
188187
189- ui64 TColumnShard::GetMinReadStep () const {
190- const TDuration maxReadStaleness = NYDBTest::TControllers::GetColumnShardController ()->GetReadTimeoutClean (MaxReadStaleness);
191- ui64 delayMillisec = maxReadStaleness.MilliSeconds ();
188+ NOlap::TSnapshot TColumnShard::GetMinReadSnapshot () const {
189+ ui64 delayMillisec = GetMaxReadStaleness ().MilliSeconds ();
192190 ui64 passedStep = GetOutdatedStep ();
193191 ui64 minReadStep = (passedStep > delayMillisec ? passedStep - delayMillisec : 0 );
194- return minReadStep;
192+ Counters.GetRequestsTracingCounters ()->OnDefaultMinSnapshotInstant (TInstant::MilliSeconds (minReadStep));
193+
194+ if (auto ssClean = InFlightReadsTracker.GetSnapshotToClean ()) {
195+ if (ssClean->GetPlanStep () < minReadStep) {
196+ return *ssClean;
197+ }
198+ }
199+ return NOlap::TSnapshot::MaxForPlanStep (minReadStep);
195200}
196201
197202TWriteId TColumnShard::HasLongTxWrite (const NLongTxService::TLongTxId& longTxId, const ui32 partId) const {
@@ -785,9 +790,8 @@ void TColumnShard::SetupCleanupPortions() {
785790 return ;
786791 }
787792
788- NOlap::TSnapshot cleanupSnapshot{GetMinReadStep (), 0 };
789-
790- auto changes = TablesManager.MutablePrimaryIndex ().StartCleanupPortions (cleanupSnapshot, TablesManager.GetPathsToDrop (), DataLocksManager);
793+ auto changes =
794+ TablesManager.MutablePrimaryIndex ().StartCleanupPortions (GetMinReadSnapshot (), TablesManager.GetPathsToDrop (), DataLocksManager);
791795 if (!changes) {
792796 ACFL_DEBUG (" background" , " cleanup" )(" skip_reason" , " no_changes" );
793797 return ;
@@ -1134,4 +1138,9 @@ const NKikimr::NColumnShard::NTiers::TManager* TColumnShard::GetTierManagerPoint
11341138 return Tiers->GetManagerOptional (tierId);
11351139}
11361140
1141+ TDuration TColumnShard::GetMaxReadStaleness () {
1142+ return NYDBTest::TControllers::GetColumnShardController ()->GetReadTimeoutClean (
1143+ TDuration::MilliSeconds (AppDataVerified ().ColumnShardConfig .GetMaxReadStaleness_ms ()));
1144+ }
1145+
11371146}
0 commit comments