Skip to content

Commit

Permalink
remove any expired shards and give empty expiry time for inf duration…
Browse files Browse the repository at this point in the history
… shards from the /show-shards output
  • Loading branch information
chengshiwen committed Sep 1, 2024
1 parent 6842d82 commit 61feb3d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion services/meta/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -945,6 +945,9 @@ func (s *store) shards() []*ClusterShardInfo {
if sgi.Deleted() {
continue
}
if rpi.Duration != 0 && sgi.EndTime.Add(rpi.Duration).Before(time.Now().UTC()) {
continue
}
for _, si := range sgi.Shards {
shardInfo := s.shardInfo(di, rpi, sgi, si)
shardInfos = append(shardInfos, shardInfo)
Expand Down Expand Up @@ -974,6 +977,10 @@ func (s *store) shard(id uint64) *ClusterShardInfo {
}

func (s *store) shardInfo(di DatabaseInfo, rpi RetentionPolicyInfo, sgi ShardGroupInfo, si ShardInfo) *ClusterShardInfo {
var expire time.Time
if rpi.Duration != 0 {
expire = sgi.EndTime.Add(rpi.Duration)
}
owners := make([]*ShardOwnerInfo, len(si.Owners))
for i, owner := range si.Owners {
n, _ := s.dataNode(owner.NodeID)
Expand All @@ -990,7 +997,7 @@ func (s *store) shardInfo(di DatabaseInfo, rpi RetentionPolicyInfo, sgi ShardGro
ShardGroupID: sgi.ID,
StartTime: sgi.StartTime,
EndTime: sgi.EndTime,
ExpireTime: sgi.EndTime.Add(rpi.Duration),
ExpireTime: expire,
TruncatedAt: sgi.TruncatedAt,
Owners: owners,
}
Expand Down

0 comments on commit 61feb3d

Please sign in to comment.