Skip to content

Commit

Permalink
Improve logging when tso keyspace group meta is updated. (tikv#6513)
Browse files Browse the repository at this point in the history
close tikv#6512

Improve logging when tso keyspace group meta is updated.

Signed-off-by: Bin Shi <binshi.bing@gmail.com>

Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
  • Loading branch information
2 people authored and rleungx committed Aug 2, 2023
1 parent f817c7e commit ecba8ae
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions pkg/tso/keyspace_group_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,6 @@ func (kgm *KeyspaceGroupManager) updateKeyspaceGroup(group *endpoint.KeyspaceGro

// If the default keyspace group isn't assigned to any tso node/pod, assign it to everyone.
if group.ID == mcsutils.DefaultKeyspaceGroupID && len(group.Members) == 0 {
log.Warn("configured the default keyspace group but no members/distribution specified. " +
"ignore it for now and fallback to the way of every tso node/pod owning a replica")
// TODO: fill members with all tso nodes/pods.
group.Members = []endpoint.KeyspaceGroupMember{{Address: kgm.tsoServiceID.ServiceAddr}}
}
Expand All @@ -373,10 +371,9 @@ func (kgm *KeyspaceGroupManager) updateKeyspaceGroup(group *endpoint.KeyspaceGro
return
}

// If this host is already assigned a replica of this keyspace group, that is to is already initialized, just update the meta.
// If this host is already assigned a replica of this keyspace group, i.e., the election member
// is already initialized, just update the meta.
if oldAM, oldGroup := kgm.getKeyspaceGroupMeta(group.ID); oldAM != nil {
log.Info("keyspace group already initialized, so update meta only",
zap.Uint32("keyspace-group-id", group.ID))
kgm.updateKeyspaceGroupMembership(oldGroup, group, true)
return
}
Expand Down Expand Up @@ -513,6 +510,12 @@ func (kgm *KeyspaceGroupManager) updateKeyspaceGroupMembership(
// The keyspace group membership is not changed. Reuse the old one.
newGroup.KeyspaceLookupTable = oldKeyspaceLookupTable
} else {
// The keyspace list might be too long, so we only log the length, though there is a rare case that
// the old length and the new length are the same but the keyspace list is changed.
log.Info("the keyspace group's keyspace list is changed",
zap.Uint32("keyspace-group-id", groupID),
zap.Int("old-keyspaces-count", oldLen),
zap.Int("new-keyspaces-count", newLen))
// The keyspace group membership is changed. Update the keyspace lookup table.
newGroup.KeyspaceLookupTable = make(map[uint32]struct{})
for i, j := 0, 0; i < oldLen || j < newLen; {
Expand Down

0 comments on commit ecba8ae

Please sign in to comment.