diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ebe4ba2c6a..6c61d897580 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 #7157 ## 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 } } }