From 6819cdffe17671a25a410f26bbc59cdabaf0a867 Mon Sep 17 00:00:00 2001 From: Alexander Kotov Date: Wed, 5 Feb 2025 13:42:49 +0300 Subject: [PATCH] [+] commments --- ydb/core/persqueue/partition.cpp | 1 + ydb/core/persqueue/partition_init.cpp | 3 +++ ydb/core/persqueue/partition_write.cpp | 1 + 3 files changed, 5 insertions(+) diff --git a/ydb/core/persqueue/partition.cpp b/ydb/core/persqueue/partition.cpp index af69c0f5e992..8380dfb89970 100644 --- a/ydb/core/persqueue/partition.cpp +++ b/ydb/core/persqueue/partition.cpp @@ -3402,6 +3402,7 @@ void TPartition::ScheduleUpdateAvailableSize(const TActorContext& ctx) { void TPartition::ClearOldHead(const ui64 offset, const ui16 partNo, TEvKeyValue::TEvRequest* request) { for (auto it = HeadKeys.rbegin(); it != HeadKeys.rend(); ++it) { if (it->Key.GetOffset() > offset || it->Key.GetOffset() == offset && it->Key.GetPartNo() >= partNo) { + // The repackaged blocks will be deleted after writing. DefferedKeysForDeletion.push_back(std::move(it->BlobKeyToken)); Y_UNUSED(request); diff --git a/ydb/core/persqueue/partition_init.cpp b/ydb/core/persqueue/partition_init.cpp index 9d15671886c0..31117feb7ccf 100644 --- a/ydb/core/persqueue/partition_init.cpp +++ b/ydb/core/persqueue/partition_init.cpp @@ -575,6 +575,9 @@ void TInitDataRangeStep::FillBlobsMetaData(const NKikimrClient::TKeyValueRespons auto& gapSize = Partition()->GapSize; auto& bodySize = Partition()->BodySize; + // If there are multiple keys for a message, then only the key that contains more messages remains. + // + // Extra keys will be added to the queue for deletion. const auto actualKeys = FilterBlobsMetaData(range, PartitionId()); diff --git a/ydb/core/persqueue/partition_write.cpp b/ydb/core/persqueue/partition_write.cpp index c38533ff605f..fce4a2360674 100644 --- a/ydb/core/persqueue/partition_write.cpp +++ b/ydb/core/persqueue/partition_write.cpp @@ -388,6 +388,7 @@ void TPartition::SyncMemoryStateWithKVState(const TActorContext& ctx) { HeadKeys.clear(); } + // New blocks have been recorded. You can now delete the keys of the repackaged blocks. DefferedKeysForDeletion.clear(); if (NewHeadKey.Size > 0) {