From c59a234e7b7e604f233f7d47e73e5df5389857ab Mon Sep 17 00:00:00 2001 From: Philip O'Toole Date: Fri, 5 Jun 2015 13:04:52 -0700 Subject: [PATCH] Deleted shard groups are not counted as "expired" --- meta/data.go | 3 +++ services/retention/service.go | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/meta/data.go b/meta/data.go index 9c0106f263..9ffa2237b1 100644 --- a/meta/data.go +++ b/meta/data.go @@ -586,6 +586,9 @@ func (rpi *RetentionPolicyInfo) ShardGroupByTimestamp(timestamp time.Time) *Shar func (rpi *RetentionPolicyInfo) ExpiredShardGroups(t time.Time) []*ShardGroupInfo { groups := make([]*ShardGroupInfo, 0) for i := range rpi.ShardGroups { + if rpi.ShardGroups[i].Deleted() { + continue + } if rpi.Duration != 0 && rpi.ShardGroups[i].EndTime.Add(rpi.Duration).Before(t) { groups = append(groups, &rpi.ShardGroups[i]) } diff --git a/services/retention/service.go b/services/retention/service.go index 49a926ce3b..6747299f63 100644 --- a/services/retention/service.go +++ b/services/retention/service.go @@ -72,7 +72,7 @@ func (s *Service) deleteShardGroups() { if !s.MetaStore.IsLeader() { continue } - s.logger.Println("retention policy enforcement commencing") + s.logger.Println("retention policy enforcement check commencing") s.MetaStore.VisitRetentionPolicies(func(d meta.DatabaseInfo, r meta.RetentionPolicyInfo) { for _, g := range r.ExpiredShardGroups(time.Now().UTC()) { @@ -101,7 +101,7 @@ func (s *Service) deleteShards() { return case <-ticker.C: - s.logger.Println("retention policy shard deletion commencing") + s.logger.Println("retention policy shard deletion check commencing") deletedShardIDs := make(map[uint64]struct{}, 0) s.MetaStore.VisitRetentionPolicies(func(d meta.DatabaseInfo, r meta.RetentionPolicyInfo) { @@ -118,7 +118,7 @@ func (s *Service) deleteShards() { s.logger.Printf("failed to delete shard ID %d: %s", id, err.Error()) continue } - s.logger.Printf("shard ID% deleted", id) + s.logger.Printf("shard ID %d deleted", id) } } }