Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions ydb/core/blobstorage/pdisk/blobstorage_pdisk_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2058,6 +2058,9 @@ void TPDisk::KillOwner(TOwner owner, TOwnerRound killOwnerRound, TCompletionEven
for (ui32 i = 0; i < ChunkState.size(); ++i) {
TChunkState &state = ChunkState[i];
if (state.OwnerId == owner) {
if (TPDisk::IS_SHRED_ENABLED) {
state.IsDirty = true;
}
if (state.CommitState == TChunkState::DATA_RESERVED
|| state.CommitState == TChunkState::DATA_DECOMMITTED
|| state.CommitState == TChunkState::DATA_RESERVED_DECOMMIT_IN_PROGRESS
Expand Down Expand Up @@ -4213,8 +4216,40 @@ void TPDisk::ProgressShredState() {
return;
}
}
// Looks good, but there still can be chunks that need to be shredded still int transition between states.
// For example, log chunks are removed from the log chunk list on log cut but added to free chunk list on log cut
// write operation completion. So, walk through the whole chunk list and check.
for (ui32 chunkIdx = Format.SystemChunkCount; chunkIdx < ChunkState.size(); ++chunkIdx) {
TChunkState &state = ChunkState[chunkIdx];
if (state.IsDirty && state.ShredGeneration < ShredGeneration) {
if (ContinueShredsInFlight) {
// There are continue shreds in flight, so we don't need to schedule a new one.
// Just wait for it to arrive.
LOG_DEBUG_S(*PCtx->ActorSystem, NKikimrServices::BS_PDISK_SHRED,
"PDisk# " << PCtx->PDiskId
<< " found a dirtyInTransition chunkIdx# " << chunkIdx
<< " state# " << state.ToString()
<< ", there are already ContinueShredsInFlight# " << ContinueShredsInFlight.load()
<< " so just wait for it to arrive. "
<< " ShredGeneration# " << ShredGeneration);
Copy link

Copilot AI Jun 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The early return within the loop means that only the first matching dirty chunk is processed per call. If this is intended, please add a comment to clarify that scheduling only one continue shred per invocation is by design.

Suggested change
<< " ShredGeneration# " << ShredGeneration);
<< " ShredGeneration# " << ShredGeneration);
// Early return is intentional: only the first matching dirty chunk is processed per invocation.
// This ensures that scheduling only one continue shred per invocation is by design.

Copilot uses AI. Check for mistakes.
return;
} else {
LOG_DEBUG_S(*PCtx->ActorSystem, NKikimrServices::BS_PDISK_SHRED,
"PDisk# " << PCtx->PDiskId
<< " found a dirtyInTransition chunkIdx# " << chunkIdx
<< " state# " << state.ToString()
<< ", scheduling ContinueShred. "
<< " ShredGeneration# " << ShredGeneration);
ContinueShredsInFlight++;
PCtx->ActorSystem->Schedule(TDuration::MilliSeconds(50),
Copy link

Copilot AI Jun 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The literal delay value '50' in TDuration::MilliSeconds(50) could be replaced with a named constant to improve readability and maintainability.

Suggested change
PCtx->ActorSystem->Schedule(TDuration::MilliSeconds(50),
PCtx->ActorSystem->Schedule(TDuration::MilliSeconds(CONTINUE_SHRED_DELAY_MS),

Copilot uses AI. Check for mistakes.
new IEventHandle(PCtx->PDiskActor, PCtx->PDiskActor, new TEvContinueShred(), 0, 0));
return;
}
}
}
ShredIsWaitingForCutLog = 0;


LOG_DEBUG_S(*PCtx->ActorSystem, NKikimrServices::BS_PDISK_SHRED,
"PDisk# " << PCtx->PDiskId
<< " has finished all shred requests"
Expand Down
Loading