Skip to content

Commit

Permalink
Use time ticker
Browse files Browse the repository at this point in the history
Signed-off-by: JmPotato <ghzpotato@gmail.com>
  • Loading branch information
JmPotato committed Jul 7, 2023
1 parent 90f2e8b commit 68bf276
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/keyspace/tso_keyspace_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,11 @@ func (m *GroupManager) MergeAllIntoDefaultKeyspaceGroup() error {
}
// Wait for the merge to finish.
ctx, cancel := context.WithTimeout(m.ctx, time.Minute)
ticker := time.NewTicker(time.Second)
cancel = func() {
cancel()
ticker.Stop()
}
checkLoop:
for {
select {
Expand All @@ -1061,7 +1066,7 @@ func (m *GroupManager) MergeAllIntoDefaultKeyspaceGroup() error {
zap.Int("merged-group-num", mergedGroupNum))
cancel()
return nil
case <-time.After(time.Second):
case <-ticker.C:
kg, err := m.GetKeyspaceGroupByID(utils.DefaultKeyspaceGroupID)
if err != nil {
log.Error("failed to check the default keyspace group merge state",
Expand Down

0 comments on commit 68bf276

Please sign in to comment.