Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mcs/tso: add log to show the progress of group cleaning up #6971

Merged
merged 2 commits into from
Aug 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions pkg/tso/keyspace_group_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,13 @@ func (s *state) getDeletedGroups() []uint32 {
return groups
}

// getDeletedGroupNum returns the number of the deleted keyspace groups.
func (s *state) getDeletedGroupNum() int {
s.RLock()
defer s.RUnlock()
return len(s.deletedGroups)
}

func (s *state) checkTSOSplit(
targetGroupID uint32,
) (splitTargetAM, splitSourceAM *AllocatorManager, err error) {
Expand Down Expand Up @@ -1391,6 +1398,11 @@ func (kgm *KeyspaceGroupManager) deletedGroupCleaner() {
defer ticker.Stop()
log.Info("deleted group cleaner is started",
zap.Duration("patrol-interval", patrolInterval))
var (
empty = true
lastDeletedGroupID uint32
lastDeletedGroupNum int
)
for {
select {
case <-kgm.ctx.Done():
Expand All @@ -1403,6 +1415,7 @@ func (kgm *KeyspaceGroupManager) deletedGroupCleaner() {
if groupID == mcsutils.DefaultKeyspaceGroupID {
continue
}
empty = false
// Make sure the allocator and group meta are not in use anymore.
am, _ := kgm.getKeyspaceGroupMeta(groupID)
if am != nil {
Expand All @@ -1428,6 +1441,18 @@ func (kgm *KeyspaceGroupManager) deletedGroupCleaner() {
kgm.Lock()
delete(kgm.deletedGroups, groupID)
kgm.Unlock()
lastDeletedGroupID = groupID
lastDeletedGroupNum += 1
}
// This log would be helpful to check if the deleted groups are all gone.
if !empty && kgm.getDeletedGroupNum() == 0 {
log.Info("all the deleted keyspace groups have been cleaned up",
zap.Uint32("last-deleted-group-id", lastDeletedGroupID),
zap.Int("last-deleted-group-num", lastDeletedGroupNum))
// Reset the state to make sure the log won't be printed again
// until we have new deleted groups.
empty = true
lastDeletedGroupNum = 0
}
}
}