@@ -457,7 +457,7 @@ func (c *Compactor) starting(ctx context.Context) error {
457457 c .bucketClient = bucketindex .BucketWithGlobalMarkers (c .bucketClient )
458458
459459 // Create the users scanner.
460- c .usersScanner = cortex_tsdb .NewUsersScanner (c .bucketClient , c .ownUser , c .parentLogger )
460+ c .usersScanner = cortex_tsdb .NewUsersScanner (c .bucketClient , c .cleanUser , c .parentLogger )
461461
462462 // Create the blocks cleaner (service).
463463 c .blocksCleaner = NewBlocksCleaner (BlocksCleanerConfig {
@@ -814,6 +814,14 @@ func (c *Compactor) discoverUsers(ctx context.Context) ([]string, error) {
814814}
815815
816816func (c * Compactor ) ownUser (userID string ) (bool , error ) {
817+ return c .ownUserHelper (userID , false )
818+ }
819+
820+ func (c * Compactor ) cleanUser (userID string ) (bool , error ) {
821+ return c .ownUserHelper (userID , true )
822+ }
823+
824+ func (c * Compactor ) ownUserHelper (userID string , isCleanUp bool ) (bool , error ) {
817825 if ! c .allowedTenants .IsAllowed (userID ) {
818826 return false , nil
819827 }
@@ -823,8 +831,8 @@ func (c *Compactor) ownUser(userID string) (bool, error) {
823831 return true , nil
824832 }
825833
826- // If using shuffle-sharding, ownership is determined by the ring
827- if c .compactorCfg .ShardingStrategy == util .ShardingStrategyShuffle {
834+ // If we aren't cleaning up user blocks, and we are using shuffle-sharding, ownership is determined by the ring
835+ if ! isCleanUp && c .compactorCfg .ShardingStrategy == util .ShardingStrategyShuffle {
828836 subRing := c .ring .ShuffleShard (userID , c .limits .CompactorTenantShardSize (userID ))
829837
830838 rs , err := subRing .GetAllHealthy (RingOp )
0 commit comments