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

keyspace, tso, apiv2: impl the interface to merge all keyspace groups into the default #6757

Merged
merged 7 commits into from
Jul 10, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add logutil.LogPanic()
Signed-off-by: JmPotato <ghzpotato@gmail.com>
  • Loading branch information
JmPotato committed Jul 10, 2023
commit 418ef5ce092dcc284d89288d6e4282577a1df8e9
1 change: 1 addition & 0 deletions pkg/keyspace/tso_keyspace_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -1015,6 +1015,7 @@

// MergeAllIntoDefaultKeyspaceGroup merges all other keyspace groups into the default keyspace group.
func (m *GroupManager) MergeAllIntoDefaultKeyspaceGroup() error {
defer logutil.LogPanic()
mergedGroupNum := 0
for i := 0; i < int(endpoint.UserKindCount); i++ {
userKind := endpoint.UserKind(i)
JmPotato marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -1022,7 +1023,7 @@
zap.Stringer("user-kind", userKind))
groups, ok := m.groups[userKind]
if !ok || groups.Len() == 0 {
continue

Check warning on line 1026 in pkg/keyspace/tso_keyspace_group.go

View check run for this annotation

Codecov / codecov/patch

pkg/keyspace/tso_keyspace_group.go#L1026

Added line #L1026 was not covered by tests
}
var (
maxBatchSize = MaxEtcdTxnOps/2 - 1
Expand All @@ -1042,12 +1043,12 @@
zap.Int("merged-group-num", mergedGroupNum))
// Reach the batch size, merge them into the default keyspace group.
if err := m.MergeKeyspaceGroups(utils.DefaultKeyspaceGroupID, groupsToMerge); err != nil {
JmPotato marked this conversation as resolved.
Show resolved Hide resolved
log.Error("failed to merge all keyspace groups into the default one",
zap.Int("index", idx),
zap.Int("batch-size", len(groupsToMerge)),
zap.Int("merged-group-num", mergedGroupNum),
zap.Error(err))
return err

Check warning on line 1051 in pkg/keyspace/tso_keyspace_group.go

View check run for this annotation

Codecov / codecov/patch

pkg/keyspace/tso_keyspace_group.go#L1046-L1051

Added lines #L1046 - L1051 were not covered by tests
}
// Wait for the merge to finish.
ctx, cancel := context.WithTimeout(m.ctx, time.Minute)
Expand All @@ -1055,25 +1056,25 @@
checkLoop:
for {
select {
case <-ctx.Done():
log.Info("cancel merging all keyspace groups into the default one",
zap.Int("index", idx),
zap.Int("batch-size", len(groupsToMerge)),
zap.Int("merged-group-num", mergedGroupNum))
cancel()
ticker.Stop()
return nil

Check warning on line 1066 in pkg/keyspace/tso_keyspace_group.go

View check run for this annotation

Codecov / codecov/patch

pkg/keyspace/tso_keyspace_group.go#L1059-L1066

Added lines #L1059 - L1066 were not covered by tests
case <-ticker.C:
kg, err := m.GetKeyspaceGroupByID(utils.DefaultKeyspaceGroupID)
if err != nil {
log.Error("failed to check the default keyspace group merge state",
zap.Int("index", idx),
zap.Int("batch-size", len(groupsToMerge)),
zap.Int("merged-group-num", mergedGroupNum),
zap.Error(err))
cancel()
ticker.Stop()
return err

Check warning on line 1077 in pkg/keyspace/tso_keyspace_group.go

View check run for this annotation

Codecov / codecov/patch

pkg/keyspace/tso_keyspace_group.go#L1070-L1077

Added lines #L1070 - L1077 were not covered by tests
}
if !kg.IsMergeTarget() {
break checkLoop
Expand Down
Loading