diff --git a/DEPS.bzl b/DEPS.bzl index 6f34be435f375..43869c2a416dc 100644 --- a/DEPS.bzl +++ b/DEPS.bzl @@ -5528,11 +5528,11 @@ def go_deps(): name = "com_github_pingcap_kvproto", build_file_proto_mode = "disable_global", importpath = "github.com/pingcap/kvproto", - sha256 = "c92084d6f9f39398a997ae0530e9e4a8acfc82b98ab17a1178c414293909f4fc", - strip_prefix = "github.com/pingcap/kvproto@v0.0.0-20260414083400-4388bfaaedab", + sha256 = "a3d3fd4f25b1de97c28f87b7faf4ba9fd86cae30b15e6007d76e66b6820089d7", + strip_prefix = "github.com/pingcap/kvproto@v0.0.0-20260601035955-b2b3bb492278", urls = [ - "https://cache.hawkingrei.com/gomod/github.com/pingcap/kvproto/com_github_pingcap_kvproto-v0.0.0-20260414083400-4388bfaaedab.zip", - "https://storage.googleapis.com/pingcapmirror/gomod/github.com/pingcap/kvproto/com_github_pingcap_kvproto-v0.0.0-20260414083400-4388bfaaedab.zip", + "https://cache.hawkingrei.com/gomod/github.com/pingcap/kvproto/com_github_pingcap_kvproto-v0.0.0-20260601035955-b2b3bb492278.zip", + "https://storage.googleapis.com/pingcapmirror/gomod/github.com/pingcap/kvproto/com_github_pingcap_kvproto-v0.0.0-20260601035955-b2b3bb492278.zip", ], ) go_repository( @@ -6596,11 +6596,11 @@ def go_deps(): build_tags = ["nextgen", "intest"], build_file_proto_mode = "disable_global", importpath = "github.com/tikv/client-go/v2", - sha256 = "c141a99a743835252241ccc913861f671f4aec654e4c5c1920ab1bdf4c3586b7", - strip_prefix = "github.com/tikv/client-go/v2@v2.0.8-0.20260511022933-fb7ee09992a7", + sha256 = "472a85fb7dccdeb0f69c6a96666a62fb41dacb73c15415707f323b9e82ba8378", + strip_prefix = "github.com/tikv/client-go/v2@v2.0.8-0.20260602013621-8804d7c60a7e", urls = [ - "https://cache.hawkingrei.com/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20260511022933-fb7ee09992a7.zip", - "https://storage.googleapis.com/pingcapmirror/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20260511022933-fb7ee09992a7.zip", + "https://cache.hawkingrei.com/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20260602013621-8804d7c60a7e.zip", + "https://storage.googleapis.com/pingcapmirror/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20260602013621-8804d7c60a7e.zip", ], ) go_repository( @@ -6608,11 +6608,11 @@ def go_deps(): build_tags = ["nextgen", "intest"], build_file_proto_mode = "disable_global", importpath = "github.com/tikv/pd/client", - sha256 = "82bae6c124099e1dd0cc921c8512f5581ace19506f9ab816d0c8eda35a7d316b", - strip_prefix = "github.com/tikv/pd/client@v0.0.0-20260404141330-8a6813497b52", + sha256 = "8f82128d68f3765fc4d71fa69b7f537cee62173968544b360786d480d6b17230", + strip_prefix = "github.com/tikv/pd/client@v0.0.0-20260601035915-3ef6a3b10c84", urls = [ - "https://cache.hawkingrei.com/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20260404141330-8a6813497b52.zip", - "https://storage.googleapis.com/pingcapmirror/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20260404141330-8a6813497b52.zip", + "https://cache.hawkingrei.com/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20260601035915-3ef6a3b10c84.zip", + "https://storage.googleapis.com/pingcapmirror/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20260601035915-3ef6a3b10c84.zip", ], ) go_repository( diff --git a/br/pkg/gc/mock_test.go b/br/pkg/gc/mock_test.go index 9ad9fad349a77..426ce3fa6ad22 100644 --- a/br/pkg/gc/mock_test.go +++ b/br/pkg/gc/mock_test.go @@ -108,8 +108,10 @@ func newTestMockPD(t *testing.T) *mockPDClient { // findBarrier finds a barrier by ID in the GC state. // Returns nil if not found. -func findBarrier(state pdgc.GCState, barrierID string) *pdgc.GCBarrierInfo { - for _, b := range state.GCBarriers { +func findBarrier(t *testing.T, state pdgc.GCState, barrierID string) *pdgc.GCBarrierInfo { + gcBarriers, err := state.GetGCBarriers() + require.NoError(t, err) + for _, b := range gcBarriers { if b.BarrierID == barrierID { return b } @@ -119,21 +121,21 @@ func findBarrier(state pdgc.GCState, barrierID string) *pdgc.GCBarrierInfo { // requireBarrier asserts that a barrier exists with the expected TS. func requireBarrier(t *testing.T, state pdgc.GCState, barrierID string, expectedTS uint64) { - barrier := findBarrier(state, barrierID) + barrier := findBarrier(t, state, barrierID) require.NotNil(t, barrier, "barrier %q should exist", barrierID) require.Equal(t, expectedTS, barrier.BarrierTS, "barrier %q TS mismatch", barrierID) } // requireNoBarrier asserts that a barrier does not exist. func requireNoBarrier(t *testing.T, state pdgc.GCState, barrierID string) { - barrier := findBarrier(state, barrierID) + barrier := findBarrier(t, state, barrierID) require.Nil(t, barrier, "barrier %q should not exist", barrierID) } // getState returns the GC state for the specified keyspace. // Use tikv.NullspaceID for global mode. func getState(ctx context.Context, t *testing.T, mockPD *mockPDClient, keyspaceID tikv.KeyspaceID) pdgc.GCState { - state, err := mockPD.GetGCStatesClient(uint32(keyspaceID)).GetGCState(ctx) + state, err := mockPD.GetGCStatesClient(uint32(keyspaceID)).GetGCState(ctx, pdgc.ExcludeGCBarriers(false)) require.NoError(t, err) return state } diff --git a/dumpling/export/util_for_test.go b/dumpling/export/util_for_test.go index 4d9e2ccc77fce..7e6ac6c12a5c6 100644 --- a/dumpling/export/util_for_test.go +++ b/dumpling/export/util_for_test.go @@ -45,7 +45,7 @@ func (m *mockGCStatesClient) DeleteGCBarrier(_ context.Context, _ string) (*pdgc return nil, nil } -func (m *mockGCStatesClient) GetGCState(_ context.Context) (pdgc.GCState, error) { +func (m *mockGCStatesClient) GetGCState(_ context.Context, _ ...pdgc.GCStatesAPIOption) (pdgc.GCState, error) { return pdgc.GCState{}, nil } @@ -57,7 +57,7 @@ func (m *mockGCStatesClient) DeleteGlobalGCBarrier(_ context.Context, _ string) return nil, nil } -func (m *mockGCStatesClient) GetAllKeyspacesGCStates(_ context.Context) (pdgc.ClusterGCStates, error) { +func (m *mockGCStatesClient) GetAllKeyspacesGCStates(_ context.Context, _ ...pdgc.GCStatesAPIOption) (pdgc.ClusterGCStates, error) { return pdgc.ClusterGCStates{}, nil } diff --git a/go.mod b/go.mod index bb1504cbc356f..ba326058e74bb 100644 --- a/go.mod +++ b/go.mod @@ -101,7 +101,7 @@ require ( github.com/pingcap/errors v0.11.5-0.20260508054701-306e305bcf41 github.com/pingcap/failpoint v0.0.0-20240528011301-b51a646c7c86 github.com/pingcap/fn v1.0.0 - github.com/pingcap/kvproto v0.0.0-20260414083400-4388bfaaedab + github.com/pingcap/kvproto v0.0.0-20260601035955-b2b3bb492278 github.com/pingcap/log v1.1.1-0.20250917021125-19901e015dc9 github.com/pingcap/metering_sdk v0.0.0-20260324055927-14fead745f1d github.com/pingcap/sysutil v1.0.1-0.20240311050922-ae81ee01f3a5 @@ -123,8 +123,8 @@ require ( github.com/stathat/consistent v1.0.0 github.com/stretchr/testify v1.11.1 github.com/tiancaiamao/appdash v0.0.0-20181126055449-889f96f722a2 - github.com/tikv/client-go/v2 v2.0.8-0.20260511022933-fb7ee09992a7 - github.com/tikv/pd/client v0.0.0-20260404141330-8a6813497b52 + github.com/tikv/client-go/v2 v2.0.8-0.20260602013621-8804d7c60a7e + github.com/tikv/pd/client v0.0.0-20260601035915-3ef6a3b10c84 github.com/timakin/bodyclose v0.0.0-20241222091800-1db5c5ca4d67 github.com/twmb/murmur3 v1.1.6 github.com/uber/jaeger-client-go v2.22.1+incompatible diff --git a/go.sum b/go.sum index c07d71cabdd3b..4519978492ae0 100644 --- a/go.sum +++ b/go.sum @@ -728,8 +728,8 @@ github.com/pingcap/fn v1.0.0/go.mod h1:u9WZ1ZiOD1RpNhcI42RucFh/lBuzTu6rw88a+oF2Z github.com/pingcap/goleveldb v0.0.0-20191226122134-f82aafb29989 h1:surzm05a8C9dN8dIUmo4Be2+pMRb6f55i+UIYrluu2E= github.com/pingcap/goleveldb v0.0.0-20191226122134-f82aafb29989/go.mod h1:O17XtbryoCJhkKGbT62+L2OlrniwqiGLSqrmdHCMzZw= github.com/pingcap/kvproto v0.0.0-20191211054548-3c6b38ea5107/go.mod h1:WWLmULLO7l8IOcQG+t+ItJ3fEcrL5FxF0Wu+HrMy26w= -github.com/pingcap/kvproto v0.0.0-20260414083400-4388bfaaedab h1:nZwtL+Fn+/EPaPby8D3b/elN2YNUZy1Mriuih/dwxqQ= -github.com/pingcap/kvproto v0.0.0-20260414083400-4388bfaaedab/go.mod h1:z6+aAHB7dBkA+LyinEX+48/ImRJ3jag0Hg0c7wkhEvE= +github.com/pingcap/kvproto v0.0.0-20260601035955-b2b3bb492278 h1:VV03wSSG2XhOwhF79lvT88Z83lwzMT+aZHXrcCIN9B0= +github.com/pingcap/kvproto v0.0.0-20260601035955-b2b3bb492278/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.0/go.mod h1:DWQW5jICDR7UJh4HtxXSM20Churx4CQL0fwL/SoOSA4= github.com/pingcap/log v1.1.1-0.20250917021125-19901e015dc9 h1:qG9BSvlWFEE5otQGamuWedx9LRm0nrHvsQRQiW8SxEs= @@ -893,10 +893,10 @@ github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY= github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28= -github.com/tikv/client-go/v2 v2.0.8-0.20260511022933-fb7ee09992a7 h1:DOYEd6c0WkPDO1RYIKVCEj771r8NGP5w9CWnOXIP7IU= -github.com/tikv/client-go/v2 v2.0.8-0.20260511022933-fb7ee09992a7/go.mod h1:rg9c3yf9lfQdj9rt5FvwRP9xDubUY6C9hyH4g9zFH1s= -github.com/tikv/pd/client v0.0.0-20260404141330-8a6813497b52 h1:fXIMowblD3qdfHXJYGJpe7SbBlTO4S9GPVZZvL3CPG8= -github.com/tikv/pd/client v0.0.0-20260404141330-8a6813497b52/go.mod h1:I2yRx/Yf8Y8kgM5f3VNp4a8fWpnjPC4TxWk554AY8bM= +github.com/tikv/client-go/v2 v2.0.8-0.20260602013621-8804d7c60a7e h1:uCI3pPDuqjG/HLCnj6neLKXviXUnQ46tAxNoq1NUato= +github.com/tikv/client-go/v2 v2.0.8-0.20260602013621-8804d7c60a7e/go.mod h1:VcMgE5O5f9aBgFrv7AQ3LGDNJ6Nlx7lJ+hmbkooC0YI= +github.com/tikv/pd/client v0.0.0-20260601035915-3ef6a3b10c84 h1:8gvjP484Hv4CNf4jKzdmQOm48hGP5wnEd86nrbVvn5o= +github.com/tikv/pd/client v0.0.0-20260601035915-3ef6a3b10c84/go.mod h1:GP9u8OBXqYQ6e43htjprZILrzn3tuogzkEEmmiNlzc4= github.com/timakin/bodyclose v0.0.0-20241222091800-1db5c5ca4d67 h1:9LPGD+jzxMlnk5r6+hJnar67cgpDIz/iyD+rfl5r2Vk= github.com/timakin/bodyclose v0.0.0-20241222091800-1db5c5ca4d67/go.mod h1:mkjARE7Yr8qU23YcGMSALbIxTQ9r9QBVahQOBRfU460= github.com/tjfoc/gmsm v1.3.2/go.mod h1:HaUcFuY0auTiaHB9MHFGCPx5IaLhTUd2atbCFBQXn9w= diff --git a/pkg/store/mockstore/unistore/tikv/mock_pd_test.go b/pkg/store/mockstore/unistore/tikv/mock_pd_test.go index 951c43025d0af..7af83e303890d 100644 --- a/pkg/store/mockstore/unistore/tikv/mock_pd_test.go +++ b/pkg/store/mockstore/unistore/tikv/mock_pd_test.go @@ -32,11 +32,23 @@ func TestMockGCStatesManager(t *testing.T) { ctl := m.GetGCInternalController(keyspaceID) cli := m.GetGCStatesClient(keyspaceID) - s, err := cli.GetGCState(ctx) + s, err := cli.GetGCState(ctx, pdgc.ExcludeGCBarriers(false)) re.NoError(err) re.Equal(uint64(0), s.GCSafePoint) re.Equal(uint64(0), s.TxnSafePoint) - re.Empty(s.GCBarriers) + re.True(s.HasGCBarriers()) + gcBarriers, err := s.GetGCBarriers() + re.NoError(err) + re.Empty(gcBarriers) + + // Test excluding GC barriers + s, err = cli.GetGCState(ctx) + re.NoError(err) + re.Equal(uint64(0), s.GCSafePoint) + re.Equal(uint64(0), s.TxnSafePoint) + re.False(s.HasGCBarriers()) + _, err = s.GetGCBarriers() + re.Error(err) tspRes, err := ctl.AdvanceTxnSafePoint(ctx, 10) re.NoError(err) @@ -59,11 +71,13 @@ func TestMockGCStatesManager(t *testing.T) { _, err = ctl.AdvanceGCSafePoint(ctx, 11) re.Error(err) - s, err = cli.GetGCState(ctx) + s, err = cli.GetGCState(ctx, pdgc.ExcludeGCBarriers(false)) re.NoError(err) re.Equal(uint64(9), s.GCSafePoint) re.Equal(uint64(10), s.TxnSafePoint) - re.Empty(s.GCBarriers) + gcBarriers, err = s.GetGCBarriers() + re.NoError(err) + re.Empty(gcBarriers) // Invalid arguments _, err = cli.SetGCBarrier(ctx, "", 20, pdgc.TTLNeverExpire) @@ -82,13 +96,24 @@ func TestMockGCStatesManager(t *testing.T) { re.Equal("b2", b.BarrierID) re.Equal(uint64(25), b.BarrierTS) + s, err = cli.GetGCState(ctx, pdgc.ExcludeGCBarriers(false)) + re.NoError(err) + re.Equal(uint64(9), s.GCSafePoint) + re.Equal(uint64(10), s.TxnSafePoint) + gcBarriers, err = s.GetGCBarriers() + re.NoError(err) + re.Len(gcBarriers, 1) + re.Equal("b2", gcBarriers[0].BarrierID) + re.Equal(uint64(25), gcBarriers[0].BarrierTS) + + // Test excluding GC barriers s, err = cli.GetGCState(ctx) re.NoError(err) re.Equal(uint64(9), s.GCSafePoint) re.Equal(uint64(10), s.TxnSafePoint) - re.Len(s.GCBarriers, 1) - re.Equal("b2", s.GCBarriers[0].BarrierID) - re.Equal(uint64(25), s.GCBarriers[0].BarrierTS) + re.False(s.HasGCBarriers()) + _, err = s.GetGCBarriers() + re.Error(err) tspRes, err = ctl.AdvanceTxnSafePoint(ctx, 30) re.NoError(err) @@ -97,7 +122,7 @@ func TestMockGCStatesManager(t *testing.T) { re.Equal(uint64(10), tspRes.OldTxnSafePoint) re.Contains(tspRes.BlockerDescription, "b2") - s, err = cli.GetGCState(ctx) + s, err = cli.GetGCState(ctx, pdgc.ExcludeGCBarriers(false)) re.NoError(err) re.Equal(uint64(25), s.TxnSafePoint) @@ -113,10 +138,12 @@ func TestMockGCStatesManager(t *testing.T) { re.Equal(uint64(25), tspRes.OldTxnSafePoint) re.Empty(tspRes.BlockerDescription) - s, err = cli.GetGCState(ctx) + s, err = cli.GetGCState(ctx, pdgc.ExcludeGCBarriers(false)) re.NoError(err) re.Equal(uint64(30), s.TxnSafePoint) re.Equal(uint64(9), s.GCSafePoint) - re.Empty(s.GCBarriers) + gcBarriers, err = s.GetGCBarriers() + re.NoError(err) + re.Empty(gcBarriers) } } diff --git a/pkg/store/mockstore/unistore/tikv/mock_region.go b/pkg/store/mockstore/unistore/tikv/mock_region.go index 3cefaca90444e..540fa9babc8b3 100644 --- a/pkg/store/mockstore/unistore/tikv/mock_region.go +++ b/pkg/store/mockstore/unistore/tikv/mock_region.go @@ -1229,7 +1229,12 @@ func (c gcStatesClient) DeleteGCBarrier(ctx context.Context, barrierID string) ( return c.inner.deleteGCBarrierImpl(ctx, c.keyspaceID, barrierID, startTime) } -func (c gcStatesClient) GetGCState(ctx context.Context) (pdgc.GCState, error) { +func (c gcStatesClient) GetGCState(ctx context.Context, opts ...pdgc.GCStatesAPIOption) (pdgc.GCState, error) { + options := pdgc.DefaultGCStatesAPIOptions() + for _, o := range opts { + o(&options) + } + startTime := time.Now() c.inner.mu.Lock() @@ -1237,19 +1242,15 @@ func (c gcStatesClient) GetGCState(ctx context.Context) (pdgc.GCState, error) { internalState := c.inner.getGCState(c.keyspaceID) - res := pdgc.GCState{ - KeyspaceID: c.keyspaceID, - TxnSafePoint: internalState.txnSafePoint, - GCSafePoint: internalState.gcSafePoint, + if options.ExcludeGCBarriers { + return pdgc.NewGCStateWithoutGCBarriers(c.keyspaceID, internalState.txnSafePoint, internalState.gcSafePoint), nil } gcBarriers := make([]*pdgc.GCBarrierInfo, 0, len(internalState.gcBarriers)) for barrierID, barrierTS := range internalState.gcBarriers { gcBarriers = append(gcBarriers, pdgc.NewGCBarrierInfo(barrierID, barrierTS, pdgc.TTLNeverExpire, startTime)) } - res.GCBarriers = gcBarriers - - return res, nil + return pdgc.NewGCStateWithGCBarriers(c.keyspaceID, internalState.txnSafePoint, internalState.gcSafePoint, gcBarriers), nil } func (c gcStatesClient) SetGlobalGCBarrier(ctx context.Context, barrierID string, barrierTS uint64, ttl time.Duration) (*pdgc.GlobalGCBarrierInfo, error) { @@ -1260,6 +1261,6 @@ func (c gcStatesClient) DeleteGlobalGCBarrier(ctx context.Context, barrierID str panic("unimplemented") } -func (c gcStatesClient) GetAllKeyspacesGCStates(ctx context.Context) (pdgc.ClusterGCStates, error) { +func (c gcStatesClient) GetAllKeyspacesGCStates(ctx context.Context, opts ...pdgc.GCStatesAPIOption) (pdgc.ClusterGCStates, error) { panic("unimplemented") }