@@ -74,7 +74,7 @@ TColumnShard::TColumnShard(TTabletStorageInfo* info, const TActorId& tablet)
74
74
, TabletCountersHolder(new TProtobufTabletCounters<ESimpleCounters_descriptor, ECumulativeCounters_descriptor,
75
75
EPercentileCounters_descriptor, ETxTypes_descriptor>())
76
76
, Counters(*TabletCountersHolder)
77
- , InFlightReadsTracker(StoragesManager)
77
+ , InFlightReadsTracker(StoragesManager, Counters.GetRequestsTracingCounters() )
78
78
, TablesManager(StoragesManager, info->TabletID)
79
79
, Subscribers(std::make_shared<NSubscriber::TManager>(*this ))
80
80
, PipeClientCache(NTabletPipe::CreateBoundedClientCache(new NTabletPipe::TBoundedClientCacheConfig(), GetPipeClientConfig()))
@@ -84,8 +84,7 @@ TColumnShard::TColumnShard(TTabletStorageInfo* info, const TActorId& tablet)
84
84
, TTLTaskSubscription(NOlap::TTTLColumnEngineChanges::StaticTypeName(), Counters.GetSubscribeCounters())
85
85
, BackgroundController(Counters.GetBackgroundControllerCounters())
86
86
, NormalizerController(StoragesManager, Counters.GetSubscribeCounters())
87
- , SysLocks(this )
88
- , MaxReadStaleness(TDuration::MilliSeconds(AppDataVerified().ColumnShardConfig.GetMaxReadStaleness_ms())) {
87
+ , SysLocks(this ) {
89
88
}
90
89
91
90
void TColumnShard::OnDetach (const TActorContext& ctx) {
@@ -186,12 +185,18 @@ ui64 TColumnShard::GetOutdatedStep() const {
186
185
return step;
187
186
}
188
187
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 ();
192
190
ui64 passedStep = GetOutdatedStep ();
193
191
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);
195
200
}
196
201
197
202
TWriteId TColumnShard::HasLongTxWrite (const NLongTxService::TLongTxId& longTxId, const ui32 partId) const {
@@ -785,9 +790,8 @@ void TColumnShard::SetupCleanupPortions() {
785
790
return ;
786
791
}
787
792
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);
791
795
if (!changes) {
792
796
ACFL_DEBUG (" background" , " cleanup" )(" skip_reason" , " no_changes" );
793
797
return ;
@@ -1134,4 +1138,9 @@ const NKikimr::NColumnShard::NTiers::TManager* TColumnShard::GetTierManagerPoint
1134
1138
return Tiers->GetManagerOptional (tierId);
1135
1139
}
1136
1140
1141
+ TDuration TColumnShard::GetMaxReadStaleness () {
1142
+ return NYDBTest::TControllers::GetColumnShardController ()->GetReadTimeoutClean (
1143
+ TDuration::MilliSeconds (AppDataVerified ().ColumnShardConfig .GetMaxReadStaleness_ms ()));
1144
+ }
1145
+
1137
1146
}
0 commit comments