From 1268b1aa74ec8f6693742ec5188d6c58d780c40c Mon Sep 17 00:00:00 2001 From: Anna Tran Date: Thu, 11 Dec 2025 16:13:23 -0800 Subject: [PATCH 1/2] Fix bug where cleaner does not delete deletable partition group Signed-off-by: Anna Tran --- CHANGELOG.md | 1 + pkg/compactor/blocks_cleaner.go | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ebe4ba2c6a..79215cc5fdd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ * [BUGFIX] Ruler: Add XFunctions validation support. #7111 * [BUGFIX] Querier: propagate Prometheus info annotations in protobuf responses. #7132 * [BUGFIX] Scheduler: Fix memory leak by properly cleaning up query fragment registry. #7148 +* [BUGFIX] Compactor: Add back deletion of partition group info file even if not complete #7129 ## 1.20.1 2025-12-03 diff --git a/pkg/compactor/blocks_cleaner.go b/pkg/compactor/blocks_cleaner.go index 6866db5f3e5..b2b9cf02777 100644 --- a/pkg/compactor/blocks_cleaner.go +++ b/pkg/compactor/blocks_cleaner.go @@ -788,11 +788,12 @@ func (c *BlocksCleaner) cleanPartitionedGroupInfo(ctx context.Context, userBucke for partitionedGroupInfo, extraInfo := range existentPartitionedGroupInfo { isPartitionGroupInfoDeleted := false partitionedGroupInfoFile := extraInfo.path + deletedBlocksCount := 0 if extraInfo.status.CanDelete { if extraInfo.status.IsCompleted { // Try to remove all blocks included in partitioned group info - deletedBlocksCount, err := partitionedGroupInfo.markAllBlocksForDeletion(ctx, userBucket, userLogger, c.blocksMarkedForDeletion, userID) + deletedBlocksCount, err = partitionedGroupInfo.markAllBlocksForDeletion(ctx, userBucket, userLogger, c.blocksMarkedForDeletion, userID) if err != nil { level.Warn(userLogger).Log("msg", "unable to mark all blocks in partitioned group info for deletion", "partitioned_group_id", partitionedGroupInfo.PartitionedGroupID) // if one block can not be marked for deletion, we should @@ -800,16 +801,17 @@ func (c *BlocksCleaner) cleanPartitionedGroupInfo(ctx context.Context, userBucke // would try it again. continue } - if deletedBlocksCount > 0 { - level.Info(userLogger).Log("msg", "parent blocks deleted, will delete partition group file in next cleaning cycle", "partitioned_group_id", partitionedGroupInfo.PartitionedGroupID) + } + + if deletedBlocksCount > 0 { + level.Info(userLogger).Log("msg", "parent blocks deleted, will delete partition group file in next cleaning cycle", "partitioned_group_id", partitionedGroupInfo.PartitionedGroupID) + } else { + level.Info(userLogger).Log("msg", "deleting partition group because either all associated blocks have been deleted or partition group is invalid", "partitioned_group_id", partitionedGroupInfo.PartitionedGroupID) + if err := userBucket.Delete(ctx, partitionedGroupInfoFile); err != nil { + level.Warn(userLogger).Log("msg", "failed to delete partitioned group info", "partitioned_group_info", partitionedGroupInfoFile, "err", err) } else { - level.Info(userLogger).Log("msg", "deleting partition group now that all associated blocks have been deleted", "partitioned_group_id", partitionedGroupInfo.PartitionedGroupID) - if err := userBucket.Delete(ctx, partitionedGroupInfoFile); err != nil { - level.Warn(userLogger).Log("msg", "failed to delete partitioned group info", "partitioned_group_info", partitionedGroupInfoFile, "err", err) - } else { - level.Info(userLogger).Log("msg", "deleted partitioned group info", "partitioned_group_info", partitionedGroupInfoFile) - isPartitionGroupInfoDeleted = true - } + level.Info(userLogger).Log("msg", "deleted partitioned group info", "partitioned_group_info", partitionedGroupInfoFile) + isPartitionGroupInfoDeleted = true } } } From 93bfc24383cc18ed043c530021559121cf397b37 Mon Sep 17 00:00:00 2001 From: Anna Tran Date: Fri, 12 Dec 2025 09:14:54 -0800 Subject: [PATCH 2/2] Fix PR issue in changelog Signed-off-by: Anna Tran --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 79215cc5fdd..6c61d897580 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,7 +19,7 @@ * [BUGFIX] Ruler: Add XFunctions validation support. #7111 * [BUGFIX] Querier: propagate Prometheus info annotations in protobuf responses. #7132 * [BUGFIX] Scheduler: Fix memory leak by properly cleaning up query fragment registry. #7148 -* [BUGFIX] Compactor: Add back deletion of partition group info file even if not complete #7129 +* [BUGFIX] Compactor: Add back deletion of partition group info file even if not complete #7157 ## 1.20.1 2025-12-03