Skip to content

Commit 1cc3829

Browse files
committed
Fix PDisk shred free chunks in transit and after vdisk deletion (#18279)
1 parent f542dde commit 1cc3829

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

ydb/core/blobstorage/pdisk/blobstorage_pdisk_impl.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2058,6 +2058,9 @@ void TPDisk::KillOwner(TOwner owner, TOwnerRound killOwnerRound, TCompletionEven
20582058
for (ui32 i = 0; i < ChunkState.size(); ++i) {
20592059
TChunkState &state = ChunkState[i];
20602060
if (state.OwnerId == owner) {
2061+
if (TPDisk::IS_SHRED_ENABLED) {
2062+
state.IsDirty = true;
2063+
}
20612064
if (state.CommitState == TChunkState::DATA_RESERVED
20622065
|| state.CommitState == TChunkState::DATA_DECOMMITTED
20632066
|| state.CommitState == TChunkState::DATA_RESERVED_DECOMMIT_IN_PROGRESS
@@ -4213,8 +4216,40 @@ void TPDisk::ProgressShredState() {
42134216
return;
42144217
}
42154218
}
4219+
// Looks good, but there still can be chunks that need to be shredded still int transition between states.
4220+
// For example, log chunks are removed from the log chunk list on log cut but added to free chunk list on log cut
4221+
// write operation completion. So, walk through the whole chunk list and check.
4222+
for (ui32 chunkIdx = Format.SystemChunkCount; chunkIdx < ChunkState.size(); ++chunkIdx) {
4223+
TChunkState &state = ChunkState[chunkIdx];
4224+
if (state.IsDirty && state.ShredGeneration < ShredGeneration) {
4225+
if (ContinueShredsInFlight) {
4226+
// There are continue shreds in flight, so we don't need to schedule a new one.
4227+
// Just wait for it to arrive.
4228+
LOG_DEBUG_S(*PCtx->ActorSystem, NKikimrServices::BS_PDISK_SHRED,
4229+
"PDisk# " << PCtx->PDiskId
4230+
<< " found a dirtyInTransition chunkIdx# " << chunkIdx
4231+
<< " state# " << state.ToString()
4232+
<< ", there are already ContinueShredsInFlight# " << ContinueShredsInFlight.load()
4233+
<< " so just wait for it to arrive. "
4234+
<< " ShredGeneration# " << ShredGeneration);
4235+
return;
4236+
} else {
4237+
LOG_DEBUG_S(*PCtx->ActorSystem, NKikimrServices::BS_PDISK_SHRED,
4238+
"PDisk# " << PCtx->PDiskId
4239+
<< " found a dirtyInTransition chunkIdx# " << chunkIdx
4240+
<< " state# " << state.ToString()
4241+
<< ", scheduling ContinueShred. "
4242+
<< " ShredGeneration# " << ShredGeneration);
4243+
ContinueShredsInFlight++;
4244+
PCtx->ActorSystem->Schedule(TDuration::MilliSeconds(50),
4245+
new IEventHandle(PCtx->PDiskActor, PCtx->PDiskActor, new TEvContinueShred(), 0, 0));
4246+
return;
4247+
}
4248+
}
4249+
}
42164250
ShredIsWaitingForCutLog = 0;
42174251

4252+
42184253
LOG_DEBUG_S(*PCtx->ActorSystem, NKikimrServices::BS_PDISK_SHRED,
42194254
"PDisk# " << PCtx->PDiskId
42204255
<< " has finished all shred requests"

0 commit comments

Comments
 (0)