Skip to content

Commit 1268b1a

Browse files
committed
Fix bug where cleaner does not delete deletable partition group
Signed-off-by: Anna Tran <trananna@amazon.com>
1 parent bb7ba54 commit 1268b1a

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
* [BUGFIX] Ruler: Add XFunctions validation support. #7111
2020
* [BUGFIX] Querier: propagate Prometheus info annotations in protobuf responses. #7132
2121
* [BUGFIX] Scheduler: Fix memory leak by properly cleaning up query fragment registry. #7148
22+
* [BUGFIX] Compactor: Add back deletion of partition group info file even if not complete #7129
2223

2324
## 1.20.1 2025-12-03
2425

pkg/compactor/blocks_cleaner.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -788,28 +788,30 @@ func (c *BlocksCleaner) cleanPartitionedGroupInfo(ctx context.Context, userBucke
788788
for partitionedGroupInfo, extraInfo := range existentPartitionedGroupInfo {
789789
isPartitionGroupInfoDeleted := false
790790
partitionedGroupInfoFile := extraInfo.path
791+
deletedBlocksCount := 0
791792

792793
if extraInfo.status.CanDelete {
793794
if extraInfo.status.IsCompleted {
794795
// Try to remove all blocks included in partitioned group info
795-
deletedBlocksCount, err := partitionedGroupInfo.markAllBlocksForDeletion(ctx, userBucket, userLogger, c.blocksMarkedForDeletion, userID)
796+
deletedBlocksCount, err = partitionedGroupInfo.markAllBlocksForDeletion(ctx, userBucket, userLogger, c.blocksMarkedForDeletion, userID)
796797
if err != nil {
797798
level.Warn(userLogger).Log("msg", "unable to mark all blocks in partitioned group info for deletion", "partitioned_group_id", partitionedGroupInfo.PartitionedGroupID)
798799
// if one block can not be marked for deletion, we should
799800
// skip delete this partitioned group. next iteration
800801
// would try it again.
801802
continue
802803
}
803-
if deletedBlocksCount > 0 {
804-
level.Info(userLogger).Log("msg", "parent blocks deleted, will delete partition group file in next cleaning cycle", "partitioned_group_id", partitionedGroupInfo.PartitionedGroupID)
804+
}
805+
806+
if deletedBlocksCount > 0 {
807+
level.Info(userLogger).Log("msg", "parent blocks deleted, will delete partition group file in next cleaning cycle", "partitioned_group_id", partitionedGroupInfo.PartitionedGroupID)
808+
} else {
809+
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)
810+
if err := userBucket.Delete(ctx, partitionedGroupInfoFile); err != nil {
811+
level.Warn(userLogger).Log("msg", "failed to delete partitioned group info", "partitioned_group_info", partitionedGroupInfoFile, "err", err)
805812
} else {
806-
level.Info(userLogger).Log("msg", "deleting partition group now that all associated blocks have been deleted", "partitioned_group_id", partitionedGroupInfo.PartitionedGroupID)
807-
if err := userBucket.Delete(ctx, partitionedGroupInfoFile); err != nil {
808-
level.Warn(userLogger).Log("msg", "failed to delete partitioned group info", "partitioned_group_info", partitionedGroupInfoFile, "err", err)
809-
} else {
810-
level.Info(userLogger).Log("msg", "deleted partitioned group info", "partitioned_group_info", partitionedGroupInfoFile)
811-
isPartitionGroupInfoDeleted = true
812-
}
813+
level.Info(userLogger).Log("msg", "deleted partitioned group info", "partitioned_group_info", partitionedGroupInfoFile)
814+
isPartitionGroupInfoDeleted = true
813815
}
814816
}
815817
}

0 commit comments

Comments
 (0)