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

*: refactor dynamic tso switch #8780

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
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
fix
Signed-off-by: Ryan Leung <rleungx@gmail.com>
rleungx committed Jan 14, 2025
commit d164f67d425de1d01f32876c9cb5e142b88a7795
14 changes: 9 additions & 5 deletions pkg/keyspace/keyspace_test.go
Original file line number Diff line number Diff line change
@@ -38,9 +38,11 @@ import (
)

const (
testConfig = "test config"
testConfig1 = "config_entry_1"
testConfig2 = "config_entry_2"
testConfig = "test config"
testConfig1 = "config_entry_1"
testConfig2 = "config_entry_2"
testGroupID = "tso_keyspace_group_id"
testUserKind = "user_kind"
)

type keyspaceTestSuite struct {
@@ -109,8 +111,10 @@ func makeCreateKeyspaceRequests(count int) []*CreateKeyspaceRequest {
requests[i] = &CreateKeyspaceRequest{
Name: fmt.Sprintf("test_keyspace_%d", i),
Config: map[string]string{
testConfig1: "100",
testConfig2: "200",
testConfig1: "100",
testConfig2: "200",
testGroupID: "0",
testUserKind: "basic",
},
CreateTime: now,
IsPreAlloc: true, // skip wait region split
8 changes: 5 additions & 3 deletions server/cluster/cluster.go
Original file line number Diff line number Diff line change
@@ -375,9 +375,11 @@ func (c *RaftCluster) Start(s Server, bootstrap bool) (err error) {

// bootstrap keyspace group manager after starting other parts successfully.
// This order avoids a stuck goroutine in keyspaceGroupManager when it fails to create raftcluster.
err = c.keyspaceGroupManager.Bootstrap(c.ctx)
if err != nil {
return err
if c.keyspaceGroupManager != nil {
err = c.keyspaceGroupManager.Bootstrap(c.ctx)
if err != nil {
return err
}
}

c.checkSchedulingService()
6 changes: 4 additions & 2 deletions server/server.go
Original file line number Diff line number Diff line change
@@ -238,7 +238,7 @@ type HandlerBuilder func(context.Context, *Server) (http.Handler, apiutil.APISer

// CreateServer creates the UNINITIALIZED pd server with given configuration.
func CreateServer(ctx context.Context, cfg *config.Config, legacyServiceBuilders ...HandlerBuilder) (*Server, error) {
// TODO: Currently, we have following combinations:
// TODO: Currently, we have following combinations for tso:
//
// There could be the following scenarios for non-serverless:
// 1. microservice + single timelines
@@ -535,7 +535,9 @@ func (s *Server) Close() {
s.cgMonitor.StopMonitor()

s.stopServerLoop()
s.keyspaceGroupManager.Close()
if s.keyspaceGroupManager != nil {
s.keyspaceGroupManager.Close()
}

if s.client != nil {
if err := s.client.Close(); err != nil {