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

Improve logging when tso keyspace group meta is updated. #6513

Merged
merged 3 commits into from
May 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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