Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 3 additions & 1 deletion client/clients/tso/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,11 @@ func (s tsoTSOStreamAdapter) Send(clusterID uint64, keyspaceID, keyspaceGroupID
req := &tsopb.TsoRequest{
Header: &tsopb.RequestHeader{
ClusterId: clusterID,
KeyspaceId: keyspaceID,
KeyspaceGroupId: keyspaceGroupID,
CalleeId: s.calleeID,
Keyspace: &tsopb.RequestHeader_KeyspaceId{
KeyspaceId: keyspaceID,
},
},
Count: uint32(count),
}
Expand Down
22 changes: 11 additions & 11 deletions client/gc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ func (c *client) updateGCSafePointV2(ctx context.Context, keyspaceID uint32, saf
ctx, cancel := context.WithTimeout(ctx, c.inner.option.Timeout)
//nolint:staticcheck
req := &pdpb.UpdateGCSafePointV2Request{
Header: c.requestHeader(),
KeyspaceId: keyspaceID,
SafePoint: safePoint,
Header: c.requestHeader(),
Keyspace: &pdpb.UpdateGCSafePointV2Request_KeyspaceId{KeyspaceId: keyspaceID},
SafePoint: safePoint,
}
protoClient, ctx := c.getClientAndContext(ctx)
if protoClient == nil {
Expand Down Expand Up @@ -75,11 +75,11 @@ func (c *client) updateServiceSafePointV2(ctx context.Context, keyspaceID uint32
ctx, cancel := context.WithTimeout(ctx, c.inner.option.Timeout)
//nolint:staticcheck
req := &pdpb.UpdateServiceSafePointV2Request{
Header: c.requestHeader(),
KeyspaceId: keyspaceID,
ServiceId: []byte(serviceID),
SafePoint: safePoint,
Ttl: ttl,
Header: c.requestHeader(),
Keyspace: &pdpb.UpdateServiceSafePointV2Request_KeyspaceId{KeyspaceId: keyspaceID},
ServiceId: []byte(serviceID),
SafePoint: safePoint,
Ttl: ttl,
}
protoClient, ctx := c.getClientAndContext(ctx)
if protoClient == nil {
Expand Down Expand Up @@ -109,7 +109,7 @@ func newGCInternalController(client *client, keyspaceID uint32) *gcInternalContr

func wrapKeyspaceScope(keyspaceID uint32) *pdpb.KeyspaceScope {
return &pdpb.KeyspaceScope{
KeyspaceId: keyspaceID,
Keyspace: &pdpb.KeyspaceScope_KeyspaceId{KeyspaceId: keyspaceID},
}
}

Expand Down Expand Up @@ -332,7 +332,7 @@ func (c gcStatesClient) GetGCState(ctx context.Context, opts ...gc.GCStatesAPIOp
func pbToGCState(pb *pdpb.GCState, reqStartTime time.Time, excludeGCBarriers bool) gc.GCState {
keyspaceID := constants.NullKeyspaceID
if pb.KeyspaceScope != nil {
keyspaceID = pb.KeyspaceScope.KeyspaceId
keyspaceID = pb.KeyspaceScope.GetKeyspaceId()
}
if excludeGCBarriers {
return gc.NewGCStateWithoutGCBarriers(keyspaceID, pb.GetTxnSafePoint(), pb.GetGcSafePoint())
Expand Down Expand Up @@ -436,7 +436,7 @@ func (c gcStatesClient) GetAllKeyspacesGCStates(ctx context.Context, opts ...gc.
if state.KeyspaceScope == nil {
keyspaceID = constants.NullKeyspaceID
} else {
keyspaceID = state.KeyspaceScope.KeyspaceId
keyspaceID = state.KeyspaceScope.GetKeyspaceId()
}
gcStates[keyspaceID] = pbToGCState(state, start, options.ExcludeGCBarriers)
}
Expand Down
2 changes: 1 addition & 1 deletion client/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/opentracing/opentracing-go v1.2.0
github.com/pingcap/errors v0.11.5-0.20211224045212-9687c2b0f87c
github.com/pingcap/failpoint v0.0.0-20240528011301-b51a646c7c86
github.com/pingcap/kvproto v0.0.0-20260622063236-b41e86365ce0
github.com/pingcap/kvproto v0.0.0-20260722060835-57fb9c0799c0
github.com/pingcap/log v1.1.1-0.20221110025148-ca232912c9f3
github.com/prometheus/client_golang v1.20.5
github.com/prometheus/client_model v0.6.1
Expand Down
4 changes: 2 additions & 2 deletions client/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ github.com/pingcap/errors v0.11.5-0.20211224045212-9687c2b0f87c h1:xpW9bvK+HuuTm
github.com/pingcap/errors v0.11.5-0.20211224045212-9687c2b0f87c/go.mod h1:X2r9ueLEUZgtx2cIogM0v4Zj5uvvzhuuiu7Pn8HzMPg=
github.com/pingcap/failpoint v0.0.0-20240528011301-b51a646c7c86 h1:tdMsjOqUR7YXHoBitzdebTvOjs/swniBTOLy5XiMtuE=
github.com/pingcap/failpoint v0.0.0-20240528011301-b51a646c7c86/go.mod h1:exzhVYca3WRtd6gclGNErRWb1qEgff3LYta0LvRmON4=
github.com/pingcap/kvproto v0.0.0-20260622063236-b41e86365ce0 h1:MalBpLjhK/cS9ndCoSAg2C7aBzVojAqFVfzTKmuy0ho=
github.com/pingcap/kvproto v0.0.0-20260622063236-b41e86365ce0/go.mod h1:z6+aAHB7dBkA+LyinEX+48/ImRJ3jag0Hg0c7wkhEvE=
github.com/pingcap/kvproto v0.0.0-20260722060835-57fb9c0799c0 h1:fYG7YB9ooFzVM7vKxXDs3QanNdj57yAMEdPZadeC64Q=
github.com/pingcap/kvproto v0.0.0-20260722060835-57fb9c0799c0/go.mod h1:z6+aAHB7dBkA+LyinEX+48/ImRJ3jag0Hg0c7wkhEvE=
github.com/pingcap/log v1.1.1-0.20221110025148-ca232912c9f3 h1:HR/ylkkLmGdSSDaD8IDP+SZrdhV1Kibl9KrHxJ9eciw=
github.com/pingcap/log v1.1.1-0.20221110025148-ca232912c9f3/go.mod h1:DWQW5jICDR7UJh4HtxXSM20Churx4CQL0fwL/SoOSA4=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
Expand Down
2 changes: 1 addition & 1 deletion client/http/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ func (meta *tempKeyspaceMeta) toPB() (*keyspacepb.KeyspaceMeta, error) {

return &keyspacepb.KeyspaceMeta{
Name: meta.Name,
Id: meta.ID,
Keyspace: &keyspacepb.KeyspaceMeta_Id{Id: meta.ID},
Config: meta.Config,
CreatedAt: meta.CreatedAt,
StateChangedAt: meta.StateChangedAt,
Expand Down
18 changes: 9 additions & 9 deletions client/keyspace_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (c *client) LoadKeyspace(ctx context.Context, name string) (*keyspacepb.Key
// Create a hardcoded keyspace meta for keyspace_1
now := time.Now().Unix()
mockKeyspaceMeta := &keyspacepb.KeyspaceMeta{
Id: 1,
Keyspace: &keyspacepb.KeyspaceMeta_Id{Id: 1},
Name: name,
CreatedAt: now,
StateChangedAt: now,
Expand Down Expand Up @@ -125,8 +125,8 @@ func (c *client) LoadKeyspaceByID(ctx context.Context, id uint32) (*keyspacepb.K
defer func() { metrics.CmdDurationLoadKeyspaceByID.Observe(time.Since(start).Seconds()) }()
ctx, cancel := context.WithTimeout(ctx, c.inner.option.Timeout)
req := &keyspacepb.LoadKeyspaceByIDRequest{
Header: c.requestHeader(),
Id: id,
Header: c.requestHeader(),
Keyspace: &keyspacepb.LoadKeyspaceByIDRequest_Id{Id: id},
}
protoClient := c.keyspaceClient()
if protoClient == nil {
Expand Down Expand Up @@ -169,9 +169,9 @@ func (c *client) UpdateKeyspaceState(ctx context.Context, id uint32, state keysp
defer func() { metrics.CmdDurationUpdateKeyspaceState.Observe(time.Since(start).Seconds()) }()
ctx, cancel := context.WithTimeout(ctx, c.inner.option.Timeout)
req := &keyspacepb.UpdateKeyspaceStateRequest{
Header: c.requestHeader(),
Id: id,
State: state,
Header: c.requestHeader(),
Keyspace: &keyspacepb.UpdateKeyspaceStateRequest_Id{Id: id},
State: state,
}
protoClient := c.keyspaceClient()
if protoClient == nil {
Expand Down Expand Up @@ -213,9 +213,9 @@ func (c *client) GetAllKeyspaces(ctx context.Context, startID uint32, limit uint
defer func() { metrics.CmdDurationGetAllKeyspaces.Observe(time.Since(start).Seconds()) }()
ctx, cancel := context.WithTimeout(ctx, c.inner.option.Timeout)
req := &keyspacepb.GetAllKeyspacesRequest{
Header: c.requestHeader(),
StartId: startID,
Limit: limit,
Header: c.requestHeader(),
StartKeyspace: &keyspacepb.GetAllKeyspacesRequest_StartId{StartId: startID},
Limit: limit,
}
protoClient := c.keyspaceClient()
if protoClient == nil {
Expand Down
6 changes: 3 additions & 3 deletions client/keyspace_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ func TestLoadKeyspaceByID(t *testing.T) {
re := require.New(t)
ctx := context.Background()
expected := &keyspacepb.KeyspaceMeta{
Id: 42,
Name: "test-keyspace",
State: keyspacepb.KeyspaceState_ENABLED,
Keyspace: &keyspacepb.KeyspaceMeta_Id{Id: 42},
Name: "test-keyspace",
State: keyspacepb.KeyspaceState_ENABLED,
}
keyspaceServer := &testKeyspaceServer{meta: expected}
addr, cleanup := startTestKeyspaceServer(t, keyspaceServer)
Expand Down
4 changes: 1 addition & 3 deletions client/resource_group/controller/global_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -742,9 +742,7 @@ func (c *ResourceGroupsController) collectTokenBucketRequests(ctx context.Contex
gc := value.(*groupCostController)
request := gc.collectRequestAndConsumption(typ)
if request != nil {
request.KeyspaceId = &rmpb.KeyspaceIDValue{
Value: c.keyspaceID,
}
request.KeyspaceId = &rmpb.KeyspaceIDValue{Keyspace: &rmpb.KeyspaceIDValue_Value{Value: c.keyspaceID}}
c.run.currentRequests = append(c.run.currentRequests, request)
gc.metrics.tokenRequestCounter.Inc()
}
Expand Down
20 changes: 6 additions & 14 deletions client/resource_manager_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,7 @@ func (c *client) ListResourceGroups(ctx context.Context, ops ...GetResourceGroup
}
req := &rmpb.ListResourceGroupsRequest{
WithRuStats: getOp.withRUStats,
KeyspaceId: &rmpb.KeyspaceIDValue{
Value: c.inner.keyspaceID,
},
KeyspaceId: &rmpb.KeyspaceIDValue{Keyspace: &rmpb.KeyspaceIDValue_Value{Value: c.inner.keyspaceID}},
}
resp, err := cc.ListResourceGroups(ctx, req)
if err != nil {
Expand Down Expand Up @@ -149,9 +147,7 @@ func (c *client) GetResourceGroup(ctx context.Context, resourceGroupName string,
req := &rmpb.GetResourceGroupRequest{
ResourceGroupName: resourceGroupName,
WithRuStats: getOp.withRUStats,
KeyspaceId: &rmpb.KeyspaceIDValue{
Value: c.inner.keyspaceID,
},
KeyspaceId: &rmpb.KeyspaceIDValue{Keyspace: &rmpb.KeyspaceIDValue_Value{Value: c.inner.keyspaceID}},
}
resp, err := cc.GetResourceGroup(ctx, req)
if err != nil {
Expand Down Expand Up @@ -192,12 +188,10 @@ func (c *client) putResourceGroup(ctx context.Context, metaGroup *rmpb.ResourceG
}
// ensure to use the keyspace ID of the inner client
if metaGroup.KeyspaceId == nil {
metaGroup.KeyspaceId = &rmpb.KeyspaceIDValue{
Value: c.inner.keyspaceID,
}
} else if metaGroup.KeyspaceId.Value != c.inner.keyspaceID {
metaGroup.KeyspaceId = &rmpb.KeyspaceIDValue{Keyspace: &rmpb.KeyspaceIDValue_Value{Value: c.inner.keyspaceID}}
} else if metaGroup.KeyspaceId.GetValue() != c.inner.keyspaceID {
return "", errs.ErrClientPutResourceGroupMismatchKeyspaceID.FastGenByArgs(
metaGroup.KeyspaceId.Value, c.inner.keyspaceID)
metaGroup.KeyspaceId.GetValue(), c.inner.keyspaceID)
}
req := &rmpb.PutResourceGroupRequest{
Group: metaGroup,
Expand Down Expand Up @@ -228,9 +222,7 @@ func (c *client) DeleteResourceGroup(ctx context.Context, resourceGroupName stri
}
req := &rmpb.DeleteResourceGroupRequest{
ResourceGroupName: resourceGroupName,
KeyspaceId: &rmpb.KeyspaceIDValue{
Value: c.inner.keyspaceID,
},
KeyspaceId: &rmpb.KeyspaceIDValue{Keyspace: &rmpb.KeyspaceIDValue_Value{Value: c.inner.keyspaceID}},
}
resp, err := cc.DeleteResourceGroup(ctx, req)
if err != nil {
Expand Down
4 changes: 1 addition & 3 deletions client/resource_manager_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,7 @@ func (s *testRMServer) AcquireTokenBuckets(stream rmpb.ResourceManager_AcquireTo
for _, tokenReq := range req.GetRequests() {
resp.Responses = append(resp.Responses, &rmpb.TokenBucketResponse{
ResourceGroupName: tokenReq.GetResourceGroupName(),
KeyspaceId: &rmpb.KeyspaceIDValue{
Value: constants.NullKeyspaceID,
},
KeyspaceId: &rmpb.KeyspaceIDValue{Keyspace: &rmpb.KeyspaceIDValue_Value{Value: constants.NullKeyspaceID}},
})
}
if err := stream.Send(resp); err != nil {
Expand Down
8 changes: 6 additions & 2 deletions client/servicediscovery/tso_service_discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -667,11 +667,15 @@ func (c *tsoServiceDiscovery) findGroupByKeyspaceID(
ctx, &tsopb.FindGroupByKeyspaceIDRequest{
Header: &tsopb.RequestHeader{
ClusterId: c.clusterID,
KeyspaceId: keyspaceID,
KeyspaceGroupId: constants.DefaultKeyspaceGroupID,
CalleeId: grpcutil.GetCalleeID(tsoSrvURL),
Keyspace: &tsopb.RequestHeader_KeyspaceId{
KeyspaceId: keyspaceID,
},
},
Keyspace: &tsopb.FindGroupByKeyspaceIDRequest_KeyspaceId{
KeyspaceId: keyspaceID,
},
KeyspaceId: keyspaceID,
ModRevision: modRevision,
})
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ require (
github.com/pingcap/errcode v0.3.0
github.com/pingcap/errors v0.11.5-0.20211224045212-9687c2b0f87c
github.com/pingcap/failpoint v0.0.0-20240528011301-b51a646c7c86
github.com/pingcap/kvproto v0.0.0-20260622063236-b41e86365ce0
github.com/pingcap/kvproto v0.0.0-20260722060835-57fb9c0799c0
github.com/pingcap/log v1.1.1-0.20221110025148-ca232912c9f3
github.com/pingcap/metering_sdk v0.0.0-20260203082503-b9f282339654
github.com/pingcap/sysutil v1.0.1-0.20230407040306-fb007c5aff21
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,8 @@ github.com/pingcap/errors v0.11.5-0.20211224045212-9687c2b0f87c/go.mod h1:X2r9ue
github.com/pingcap/failpoint v0.0.0-20240528011301-b51a646c7c86 h1:tdMsjOqUR7YXHoBitzdebTvOjs/swniBTOLy5XiMtuE=
github.com/pingcap/failpoint v0.0.0-20240528011301-b51a646c7c86/go.mod h1:exzhVYca3WRtd6gclGNErRWb1qEgff3LYta0LvRmON4=
github.com/pingcap/kvproto v0.0.0-20191211054548-3c6b38ea5107/go.mod h1:WWLmULLO7l8IOcQG+t+ItJ3fEcrL5FxF0Wu+HrMy26w=
github.com/pingcap/kvproto v0.0.0-20260622063236-b41e86365ce0 h1:MalBpLjhK/cS9ndCoSAg2C7aBzVojAqFVfzTKmuy0ho=
github.com/pingcap/kvproto v0.0.0-20260622063236-b41e86365ce0/go.mod h1:z6+aAHB7dBkA+LyinEX+48/ImRJ3jag0Hg0c7wkhEvE=
github.com/pingcap/kvproto v0.0.0-20260722060835-57fb9c0799c0 h1:fYG7YB9ooFzVM7vKxXDs3QanNdj57yAMEdPZadeC64Q=
github.com/pingcap/kvproto v0.0.0-20260722060835-57fb9c0799c0/go.mod h1:z6+aAHB7dBkA+LyinEX+48/ImRJ3jag0Hg0c7wkhEvE=
github.com/pingcap/log v0.0.0-20210625125904-98ed8e2eb1c7/go.mod h1:8AanEdAHATuRurdGxZXBz0At+9avep+ub7U1AGYLIMM=
github.com/pingcap/log v1.1.1-0.20221110025148-ca232912c9f3 h1:HR/ylkkLmGdSSDaD8IDP+SZrdhV1Kibl9KrHxJ9eciw=
github.com/pingcap/log v1.1.1-0.20221110025148-ca232912c9f3/go.mod h1:DWQW5jICDR7UJh4HtxXSM20Churx4CQL0fwL/SoOSA4=
Expand Down
6 changes: 3 additions & 3 deletions pkg/gc/gc_state_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,7 @@ func (m *GCStateManager) iterateAllKeyspacesGCStates(

if keyspaceMeta.Config[keyspace.GCManagementType] != keyspace.KeyspaceLevelGC {
gcState := GCState{
KeyspaceID: keyspaceMeta.Id,
KeyspaceID: keyspaceMeta.GetId(),
IsKeyspaceLevel: false,
}
cb(gcState)
Expand Down Expand Up @@ -1262,15 +1262,15 @@ func (m *GCStateManager) getMaxTxnSafePointAmongAllKeyspaces(_ *endpoint.GCState
if keyspaceMeta.State != keyspacepb.KeyspaceState_ENABLED {
continue
}
txnSafePoint, err2 := m.gcMetaStorage.LoadTxnSafePoint(keyspaceMeta.Id)
txnSafePoint, err2 := m.gcMetaStorage.LoadTxnSafePoint(keyspaceMeta.GetId())
if err2 != nil {
err = err2
return
}
if txnSafePoint > maxTxnSafePoint {
maxTxnSafePoint = txnSafePoint
keyspaceName = keyspaceMeta.Name
keyspaceID = keyspaceMeta.Id
keyspaceID = keyspaceMeta.GetId()
}
}
// NOTE, allKeyspaces by LoadRangeKeyspace() do not contain the null keyspace!
Expand Down
8 changes: 4 additions & 4 deletions pkg/gc/gc_state_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func newGCStateManagerForTest(t testing.TB, opt newGCStateManagerForTestOptions)
CreateTime: time.Now().Unix(),
})
re.NoError(err)
re.Equal(uint32(1), ks1.Id)
re.Equal(uint32(1), ks1.GetId())

*id = 2
ks2, err := keyspaceManager.CreateKeyspaceByID(&keyspace.CreateKeyspaceByIDRequest{
Expand All @@ -178,7 +178,7 @@ func newGCStateManagerForTest(t testing.TB, opt newGCStateManagerForTestOptions)
CreateTime: time.Now().Unix(),
})
re.NoError(err)
re.Equal(uint32(2), ks2.Id)
re.Equal(uint32(2), ks2.GetId())

*id = 3
ks3, err := keyspaceManager.CreateKeyspaceByID(&keyspace.CreateKeyspaceByIDRequest{
Expand All @@ -188,7 +188,7 @@ func newGCStateManagerForTest(t testing.TB, opt newGCStateManagerForTestOptions)
CreateTime: time.Now().Unix(),
})
re.NoError(err)
re.Equal(uint32(3), ks3.Id)
re.Equal(uint32(3), ks3.GetId())

*id = 4
ks4, err := keyspaceManager.CreateKeyspaceByID(&keyspace.CreateKeyspaceByIDRequest{
Expand All @@ -200,7 +200,7 @@ func newGCStateManagerForTest(t testing.TB, opt newGCStateManagerForTestOptions)
re.NoError(err)
_, err = keyspaceManager.UpdateKeyspaceState("ks4", keyspacepb.KeyspaceState_DISABLED, time.Now().Unix())
re.NoError(err)
re.Equal(uint32(4), ks4.Id)
re.Equal(uint32(4), ks4.GetId())
} else {
for _, req := range opt.specifyInitialKeyspaces {
_, err := keyspaceManager.CreateKeyspaceByID(req)
Expand Down
Loading
Loading