@@ -24,11 +24,12 @@ namespace NKikimr {
24
24
25
25
THashMap<TChunkIdx, EChunkType> ChunkTypes;
26
26
THashSet<TChunkIdx> ChunksShredded;
27
- THashSet<ui64> TablesToCompact;
27
+ THashSet<ui64> TablesToCompactLogoBlobs;
28
+ THashSet<ui64> TablesToCompactBlocks;
29
+ THashSet<ui64> TablesToCompactBarriers;
28
30
ui32 RepliesPending = 0 ;
29
31
bool SnapshotProcessed = false ;
30
32
bool DefragCompleted = false ;
31
- bool FoundAnyChunks = false ;
32
33
33
34
public:
34
35
TSkeletonShredActor (NPDisk::TEvShredVDisk::TPtr ev, TShredCtxPtr shredCtx)
@@ -71,7 +72,6 @@ namespace NKikimr {
71
72
RepliesPending = 2 ;
72
73
SnapshotProcessed = false ;
73
74
DefragCompleted = false ;
74
- FoundAnyChunks = false ;
75
75
}
76
76
77
77
void Handle (TEvListChunksResult::TPtr ev) {
@@ -84,7 +84,6 @@ namespace NKikimr {
84
84
for (const TChunkIdx chunkId : set) {
85
85
if (const auto it = ChunkTypes.find (chunkId); it != ChunkTypes.end ()) {
86
86
it->second = type;
87
- FoundAnyChunks = true ;
88
87
Y_DEBUG_ABORT_UNLESS (ChunksToShred.contains (chunkId));
89
88
} else {
90
89
Y_DEBUG_ABORT_UNLESS (!ChunksToShred.contains (chunkId));
@@ -104,15 +103,20 @@ namespace NKikimr {
104
103
(ActorId, SelfId ()));
105
104
106
105
auto & snap = ev->Get ()->Snap ;
107
- TablesToCompact.clear ();
108
- Scan<true >(snap.HullCtx , snap.LogoBlobsSnap , TablesToCompact);
109
- Scan<false >(snap.HullCtx , snap.BlocksSnap , TablesToCompact);
110
- Scan<false >(snap.HullCtx , snap.BarriersSnap , TablesToCompact);
106
+ TablesToCompactLogoBlobs.clear ();
107
+ TablesToCompactBlocks.clear ();
108
+ TablesToCompactBarriers.clear ();
109
+ Scan<true >(snap.HullCtx , snap.LogoBlobsSnap , TablesToCompactLogoBlobs);
110
+ Scan<false >(snap.HullCtx , snap.BlocksSnap , TablesToCompactBlocks);
111
+ Scan<false >(snap.HullCtx , snap.BarriersSnap , TablesToCompactBarriers);
111
112
SnapshotProcessed = true ;
113
+ DropUnknownChunks ();
114
+ CheckIfDone ();
112
115
CheckDefragStage ();
113
116
114
117
STLOG (PRI_DEBUG, BS_SHRED, BSSV09, ShredCtx->VCtx ->VDiskLogPrefix << " TEvTakeHullSnapshotResult processed" ,
115
- (ActorId, SelfId ()), (TablesToCompact, TablesToCompact));
118
+ (ActorId, SelfId ()), (TablesToCompactLogoBlobs, TablesToCompactLogoBlobs),
119
+ (TablesToCompactBlocks, TablesToCompactBlocks), (TablesToCompactBarriers, TablesToCompactBarriers));
116
120
}
117
121
118
122
template <bool Blobs, typename TKey, typename TMemRec>
@@ -128,7 +132,6 @@ namespace NKikimr {
128
132
}
129
133
if (const auto it = ChunkTypes.find (p->ChunkIdx ); it != ChunkTypes.end ()) {
130
134
it->second = EChunkType::HUGE_CHUNK;
131
- FoundAnyChunks = true ;
132
135
}
133
136
}
134
137
}
@@ -155,7 +158,6 @@ namespace NKikimr {
155
158
tablesToCompact.insert (seg.AssignedSstId );
156
159
STLOG (PRI_DEBUG, BS_SHRED, BSSV13, ShredCtx->VCtx ->VDiskLogPrefix << " going to compact SST" ,
157
160
(SstId, seg.AssignedSstId ), (AllChunks, seg.AllChunks ));
158
- FoundAnyChunks = true ;
159
161
Y_DEBUG_ABORT_UNLESS (ChunksToShred.contains (chunkId));
160
162
} else {
161
163
Y_DEBUG_ABORT_UNLESS (!ChunksToShred.contains (chunkId));
@@ -172,6 +174,19 @@ namespace NKikimr {
172
174
}
173
175
}
174
176
177
+ void DropUnknownChunks () {
178
+ for (auto it = ChunkTypes.begin (); it != ChunkTypes.end (); ) {
179
+ if (it->second == EChunkType::UNKNOWN) {
180
+ const size_t num = ChunksToShred.erase (it->first );
181
+ Y_VERIFY_DEBUG_S (num == 1 , ShredCtx->VCtx ->VDiskLogPrefix );
182
+ ChunksShredded.insert (it->first );
183
+ ChunkTypes.erase (it++);
184
+ } else {
185
+ ++it;
186
+ }
187
+ }
188
+ }
189
+
175
190
void HandleHullShredDefragResult () {
176
191
STLOG (PRI_DEBUG, BS_SHRED, BSSV14, ShredCtx->VCtx ->VDiskLogPrefix << " EvHullShredDefragResult received" ,
177
192
(ActorId, SelfId ()));
@@ -184,8 +199,15 @@ namespace NKikimr {
184
199
return ;
185
200
}
186
201
187
- if (!TablesToCompact.empty ()) {
188
- Send (ShredCtx->SkeletonId , TEvCompactVDisk::Create (EHullDbType::LogoBlobs, std::move (TablesToCompact)));
202
+ if (!TablesToCompactLogoBlobs.empty ()) {
203
+ Send (ShredCtx->SkeletonId , TEvCompactVDisk::Create (EHullDbType::LogoBlobs,
204
+ std::exchange (TablesToCompactLogoBlobs, {})));
205
+ } else if (!TablesToCompactBlocks.empty ()) {
206
+ Send (ShredCtx->SkeletonId , TEvCompactVDisk::Create (EHullDbType::Blocks,
207
+ std::exchange (TablesToCompactBlocks, {})));
208
+ } else if (!TablesToCompactBarriers.empty ()) {
209
+ Send (ShredCtx->SkeletonId , TEvCompactVDisk::Create (EHullDbType::Barriers,
210
+ std::exchange (TablesToCompactBarriers, {})));
189
211
} else {
190
212
TActivationContext::Schedule (TDuration::Minutes (1 ), new IEventHandle (TEvents::TSystem::Wakeup, 0 ,
191
213
SelfId (), TActorId (), nullptr , 0 ));
@@ -195,8 +217,7 @@ namespace NKikimr {
195
217
void Handle (TEvCompactVDiskResult::TPtr /* ev*/ ) {
196
218
STLOG (PRI_DEBUG, BS_SHRED, BSSV11, ShredCtx->VCtx ->VDiskLogPrefix << " TEvCompactVDiskResult received" ,
197
219
(ActorId, SelfId ()));
198
- TActivationContext::Schedule (TDuration::Minutes (1 ), new IEventHandle (TEvents::TSystem::Wakeup, 0 , SelfId (),
199
- TActorId (), nullptr , 0 ));
220
+ CheckDefragStage ();
200
221
}
201
222
202
223
void Handle (TEvNotifyChunksDeleted::TPtr ev) {
0 commit comments