diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index 3ccb2635e9f..6bbca199c0c 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -12,7 +12,7 @@ jobs: uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: '1.21' + go-version: '1.23' - name: Make Check run: | SWAGGER=1 make build diff --git a/.github/workflows/pd-docker-image.yaml b/.github/workflows/pd-docker-image.yaml index 5beaa66c156..a0d1817abdb 100644 --- a/.github/workflows/pd-docker-image.yaml +++ b/.github/workflows/pd-docker-image.yaml @@ -19,6 +19,6 @@ jobs: uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: '1.21' + go-version: '1.23' - name: Make run: make docker-image diff --git a/.github/workflows/pd-tests.yaml b/.github/workflows/pd-tests.yaml index c2469d64a31..1464c696db3 100644 --- a/.github/workflows/pd-tests.yaml +++ b/.github/workflows/pd-tests.yaml @@ -53,7 +53,7 @@ jobs: uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: '1.21' + go-version: '1.23' - name: ${{ matrix.name }} env: WORKER_ID: ${{ matrix.worker_id }} diff --git a/.github/workflows/tso-consistency-test.yaml b/.github/workflows/tso-consistency-test.yaml index 3cb24898a10..5fb0fd70552 100644 --- a/.github/workflows/tso-consistency-test.yaml +++ b/.github/workflows/tso-consistency-test.yaml @@ -12,6 +12,6 @@ jobs: uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: '1.21' + go-version: '1.23' - name: Make TSO Consistency Test run: make test-tso-consistency diff --git a/.github/workflows/tso-function-test.yaml b/.github/workflows/tso-function-test.yaml index 13fd6fe7df6..98fda23b28e 100644 --- a/.github/workflows/tso-function-test.yaml +++ b/.github/workflows/tso-function-test.yaml @@ -25,6 +25,6 @@ jobs: uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: '1.21' + go-version: '1.23' - name: Make TSO Function Test run: make test-tso-function diff --git a/.golangci.yml b/.golangci.yml index e5b5fe1ab56..ddca6d63d2a 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -15,7 +15,7 @@ linters: - gofmt - revive - errcheck - - exportloopref + - copyloopvar - goimports - depguard linters-settings: @@ -32,6 +32,8 @@ linters-settings: excludes: - G402 - G404 + # TODO: enable G115 after fixing the issues + - G115 testifylint: enable: - bool-compare diff --git a/Dockerfile b/Dockerfile index d3f0025023b..a1dec2a8b94 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.21-alpine as builder +FROM golang:1.23-alpine as builder RUN apk add --no-cache \ make \ diff --git a/Makefile b/Makefile index 0cba7051a29..51a1b04b71c 100644 --- a/Makefile +++ b/Makefile @@ -170,7 +170,7 @@ SHELL := env PATH='$(PATH)' GOBIN='$(GO_TOOLS_BIN_PATH)' $(shell which bash) install-tools: @mkdir -p $(GO_TOOLS_BIN_PATH) - @which golangci-lint >/dev/null 2>&1 || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GO_TOOLS_BIN_PATH) v1.56.2 + @which golangci-lint >/dev/null 2>&1 || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GO_TOOLS_BIN_PATH) v1.61.0 @grep '_' tools.go | sed 's/"//g' | awk '{print $$2}' | xargs go install .PHONY: install-tools diff --git a/README.md b/README.md index 564e7adedd2..c2147522768 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ If you're interested in contributing to PD, see [CONTRIBUTING.md](./CONTRIBUTING ## Build -1. Make sure [*Go*](https://golang.org/) (version 1.21) is installed. +1. Make sure [*Go*](https://golang.org/) (version 1.23) is installed. 2. Use `make` to install PD. `pd-server` will be installed in the `bin` directory. ## Usage diff --git a/client/client.go b/client/client.go index ba4741e4ed9..3faa3a09215 100644 --- a/client/client.go +++ b/client/client.go @@ -1705,7 +1705,7 @@ func (c *client) GetExternalTimestamp(ctx context.Context) (uint64, error) { } resErr := resp.GetHeader().GetError() if resErr != nil { - return 0, errors.Errorf("[pd]" + resErr.Message) + return 0, errors.New("[pd]" + resErr.Message) } return resp.GetTimestamp(), nil } @@ -1727,7 +1727,7 @@ func (c *client) SetExternalTimestamp(ctx context.Context, timestamp uint64) err } resErr := resp.GetHeader().GetError() if resErr != nil { - return errors.Errorf("[pd]" + resErr.Message) + return errors.New("[pd]" + resErr.Message) } return nil } diff --git a/client/go.mod b/client/go.mod index f8c1a394e3c..a8129722dd3 100644 --- a/client/go.mod +++ b/client/go.mod @@ -1,6 +1,6 @@ module github.com/tikv/pd/client -go 1.21 +go 1.23 require ( github.com/BurntSushi/toml v0.3.1 diff --git a/client/resource_manager_client.go b/client/resource_manager_client.go index 45182c07d3a..11e798a89fb 100644 --- a/client/resource_manager_client.go +++ b/client/resource_manager_client.go @@ -198,7 +198,7 @@ func (c *client) LoadResourceGroups(ctx context.Context) ([]*rmpb.ResourceGroup, return nil, 0, err } if resp.Header.Error != nil { - return nil, resp.Header.Revision, errors.Errorf(resp.Header.Error.Message) + return nil, resp.Header.Revision, errors.New(resp.Header.Error.Message) } groups := make([]*rmpb.ResourceGroup, 0, len(resp.Kvs)) for _, item := range resp.Kvs { diff --git a/cmd/pd-server/main.go b/cmd/pd-server/main.go index 459b18605e9..443a50c6811 100644 --- a/cmd/pd-server/main.go +++ b/cmd/pd-server/main.go @@ -70,7 +70,7 @@ func main() { rootCmd.SetOutput(os.Stdout) if err := rootCmd.Execute(); err != nil { rootCmd.Println(err) - os.Exit(1) + exit(1) } } diff --git a/go.mod b/go.mod index 8a57cfc4994..0e4143a0f6f 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/tikv/pd -go 1.21 +go 1.23 // When you modify PD cooperatively with kvproto, this will be useful to submit the PR to PD and the PR to // kvproto at the same time. You can run `go mod tidy` to make it replaced with go-mod style specification. @@ -40,7 +40,7 @@ require ( github.com/pingcap/tidb-dashboard v0.0.0-20240924035706-618b5cded5bf github.com/prometheus/client_golang v1.19.0 github.com/prometheus/common v0.51.1 - github.com/sasha-s/go-deadlock v0.2.0 + github.com/sasha-s/go-deadlock v0.3.5 github.com/shirou/gopsutil/v3 v3.23.3 github.com/smallnest/chanx v1.2.1-0.20240521153536-01121e21ff99 github.com/soheilhy/cmux v0.1.5 @@ -149,7 +149,7 @@ require ( github.com/oleiade/reflections v1.0.1 // indirect github.com/onsi/gomega v1.20.1 // indirect github.com/pelletier/go-toml/v2 v2.2.2 // indirect - github.com/petermattis/goid v0.0.0-20211229010228-4d14c490ee36 // indirect + github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 // indirect github.com/pingcap/tipb v0.0.0-20220718022156-3e2483c20a9e // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect diff --git a/go.sum b/go.sum index 943820a10e1..590caeefc07 100644 --- a/go.sum +++ b/go.sum @@ -374,8 +374,8 @@ github.com/pascaldekloe/name v0.0.0-20180628100202-0fd16699aae1/go.mod h1:eD5Jxq github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo= github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= -github.com/petermattis/goid v0.0.0-20211229010228-4d14c490ee36 h1:64bxqeTEN0/xoEqhKGowgihNuzISS9rEG6YUMU4bzJo= -github.com/petermattis/goid v0.0.0-20211229010228-4d14c490ee36/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4= +github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 h1:Dx7Ovyv/SFnMFw3fD4oEoeorXc6saIiQ23LrGLth0Gw= +github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4= github.com/phf/go-queue v0.0.0-20170504031614-9abe38d0371d h1:U+PMnTlV2tu7RuMK5etusZG3Cf+rpow5hqQByeCzJ2g= github.com/phf/go-queue v0.0.0-20170504031614-9abe38d0371d/go.mod h1:lXfE4PvvTW5xOjO6Mba8zDPyw8M93B6AQ7frTGnMlA8= github.com/pingcap/check v0.0.0-20191216031241-8a5a85928f12 h1:rfD9v3+ppLPzoQBgZev0qYCpegrwyFx/BUpkApEiKdY= @@ -432,8 +432,8 @@ github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/samber/lo v1.37.0 h1:XjVcB8g6tgUp8rsPsJ2CvhClfImrpL04YpQHXeHPhRw= github.com/samber/lo v1.37.0/go.mod h1:9vaz2O4o8oOnK23pd2TrXufcbdbJIa3b6cstBWKpopA= -github.com/sasha-s/go-deadlock v0.2.0 h1:lMqc+fUb7RrFS3gQLtoQsJ7/6TV/pAIFvBsqX73DK8Y= -github.com/sasha-s/go-deadlock v0.2.0/go.mod h1:StQn567HiB1fF2yJ44N9au7wOhrPS3iZqiDbRupzT10= +github.com/sasha-s/go-deadlock v0.3.5 h1:tNCOEEDG6tBqrNDOX35j/7hL5FcFViG6awUGROb2NsU= +github.com/sasha-s/go-deadlock v0.3.5/go.mod h1:bugP6EGbdGYObIlx7pUZtWqlvo8k9H6vCBBsiChJQ5U= github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/shirou/gopsutil/v3 v3.21.12/go.mod h1:BToYZVTlSVlfazpDDYFnsVZLaoRG+g8ufT6fPQLdJzA= diff --git a/pkg/gc/safepoint.go b/pkg/gc/safepoint.go index be12cfb78a5..c1b4687e109 100644 --- a/pkg/gc/safepoint.go +++ b/pkg/gc/safepoint.go @@ -56,7 +56,7 @@ func (manager *SafePointManager) UpdateGCSafePoint(newSafePoint uint64) (oldSafe return } if manager.cfg.BlockSafePointV1 { - err = errors.Errorf(blockGCSafePointErrmsg) + err = errors.New(blockGCSafePointErrmsg) return } @@ -73,7 +73,7 @@ func (manager *SafePointManager) UpdateGCSafePoint(newSafePoint uint64) (oldSafe // UpdateServiceGCSafePoint update the safepoint for a specific service. func (manager *SafePointManager) UpdateServiceGCSafePoint(serviceID string, newSafePoint uint64, ttl int64, now time.Time) (minServiceSafePoint *endpoint.ServiceSafePoint, updated bool, err error) { if manager.cfg.BlockSafePointV1 { - return nil, false, errors.Errorf(blockServiceSafepointErrmsg) + return nil, false, errors.New(blockServiceSafepointErrmsg) } manager.serviceGCLock.Lock() defer manager.serviceGCLock.Unlock() diff --git a/pkg/mcs/tso/server/grpc_service.go b/pkg/mcs/tso/server/grpc_service.go index 7dd9c6b5605..44083eb9a63 100644 --- a/pkg/mcs/tso/server/grpc_service.go +++ b/pkg/mcs/tso/server/grpc_service.go @@ -117,7 +117,7 @@ func (s *Service) Tso(stream tsopb.TSO_TsoServer) error { keyspaceID, keyspaceGroupID, dcLocation, count) if err != nil { - return status.Errorf(codes.Unknown, err.Error()) + return status.Error(codes.Unknown, err.Error()) } keyspaceGroupIDStr := strconv.FormatUint(uint64(keyspaceGroupID), 10) tsoHandleDuration.WithLabelValues(keyspaceGroupIDStr).Observe(time.Since(start).Seconds()) diff --git a/pkg/schedule/filter/candidates_test.go b/pkg/schedule/filter/candidates_test.go index 2e81c747353..fd03b42ace0 100644 --- a/pkg/schedule/filter/candidates_test.go +++ b/pkg/schedule/filter/candidates_test.go @@ -97,7 +97,7 @@ func TestCandidates(t *testing.T) { cs.Sort(idComparer) check(re, cs, 1, 2, 3, 4, 5, 6, 7) store = cs.RandomPick() - re.Greater(store.GetID(), uint64(0)) + re.Positive(store.GetID()) re.Less(store.GetID(), uint64(8)) cs = newTestCandidates(10, 15, 23, 20, 33, 32, 31) diff --git a/pkg/unsaferecovery/unsafe_recovery_controller_test.go b/pkg/unsaferecovery/unsafe_recovery_controller_test.go index 4eeed08077c..5284b372758 100644 --- a/pkg/unsaferecovery/unsafe_recovery_controller_test.go +++ b/pkg/unsaferecovery/unsafe_recovery_controller_test.go @@ -224,8 +224,8 @@ func TestFinished(t *testing.T) { recoveryController.HandleStoreHeartbeat(req, resp) // require peer report by empty plan re.NotNil(resp.RecoveryPlan) - re.Empty(len(resp.RecoveryPlan.Creates)) - re.Empty(len(resp.RecoveryPlan.Demotes)) + re.Empty(resp.RecoveryPlan.Creates) + re.Empty(resp.RecoveryPlan.Demotes) re.Nil(resp.RecoveryPlan.ForceLeader) re.Equal(uint64(1), resp.RecoveryPlan.Step) applyRecoveryPlan(re, storeID, reports, resp) @@ -304,8 +304,8 @@ func TestFailed(t *testing.T) { resp := &pdpb.StoreHeartbeatResponse{} recoveryController.HandleStoreHeartbeat(req, resp) re.NotNil(resp.RecoveryPlan) - re.Empty(len(resp.RecoveryPlan.Creates)) - re.Empty(len(resp.RecoveryPlan.Demotes)) + re.Empty(resp.RecoveryPlan.Creates) + re.Empty(resp.RecoveryPlan.Demotes) re.Nil(resp.RecoveryPlan.ForceLeader) applyRecoveryPlan(re, storeID, reports, resp) } @@ -604,7 +604,7 @@ func TestAutoDetectMode(t *testing.T) { if result, ok := expects[storeID]; ok { re.Equal(result.PeerReports, report.PeerReports) } else { - re.Empty(len(report.PeerReports)) + re.Empty(report.PeerReports) } } } @@ -701,7 +701,7 @@ func TestOneLearner(t *testing.T) { if result, ok := expects[storeID]; ok { re.Equal(result.PeerReports, report.PeerReports) } else { - re.Empty(len(report.PeerReports)) + re.Empty(report.PeerReports) } } } @@ -876,7 +876,7 @@ func TestTiflashLearnerPeer(t *testing.T) { if result, ok := expects[storeID]; ok { re.Equal(result.PeerReports, report.PeerReports) } else { - re.Empty(len(report.PeerReports)) + re.Empty(report.PeerReports) } } } @@ -1125,7 +1125,7 @@ func TestJointState(t *testing.T) { if result, ok := expects[storeID]; ok { re.Equal(result.PeerReports, report.PeerReports) } else { - re.Empty(len(report.PeerReports)) + re.Empty(report.PeerReports) } } } @@ -1258,7 +1258,7 @@ func TestExitForceLeader(t *testing.T) { if result, ok := expects[storeID]; ok { re.Equal(result.PeerReports, report.PeerReports) } else { - re.Empty(len(report.PeerReports)) + re.Empty(report.PeerReports) } } } @@ -1375,8 +1375,8 @@ func TestOnHealthyRegions(t *testing.T) { resp := &pdpb.StoreHeartbeatResponse{} recoveryController.HandleStoreHeartbeat(req, resp) re.NotNil(resp.RecoveryPlan) - re.Empty(len(resp.RecoveryPlan.Creates)) - re.Empty(len(resp.RecoveryPlan.Demotes)) + re.Empty(resp.RecoveryPlan.Creates) + re.Empty(resp.RecoveryPlan.Demotes) re.Nil(resp.RecoveryPlan.ForceLeader) applyRecoveryPlan(re, storeID, reports, resp) } @@ -1486,7 +1486,7 @@ func TestCreateEmptyRegion(t *testing.T) { if expect, ok := expects[storeID]; ok { re.Equal(expect.PeerReports, report.PeerReports) } else { - re.Empty(len(report.PeerReports)) + re.Empty(report.PeerReports) } } } @@ -1593,7 +1593,7 @@ func TestRangeOverlap1(t *testing.T) { if result, ok := expects[storeID]; ok { re.Equal(result.PeerReports, report.PeerReports) } else { - re.Empty(len(report.PeerReports)) + re.Empty(report.PeerReports) } } } diff --git a/pkg/utils/reflectutil/tag.go b/pkg/utils/reflectutil/tag.go index 1d04d25502b..6b5987ea900 100644 --- a/pkg/utils/reflectutil/tag.go +++ b/pkg/utils/reflectutil/tag.go @@ -66,13 +66,15 @@ func FindFieldByJSONTag(t reflect.Type, tags []string) reflect.Type { if t.Kind() != reflect.Struct { return nil } + tag := tags[0] + tagRemain := tags[1:] for i := 0; i < t.NumField(); i++ { jsonTag := t.Field(i).Tag.Get("json") - if i := strings.Index(jsonTag, ","); i != -1 { // trim 'foobar,string' to 'foobar' - jsonTag = jsonTag[:i] + if j := strings.Index(jsonTag, ","); j != -1 { // trim 'foobar,string' to 'foobar' + jsonTag = jsonTag[:j] } - if jsonTag == tags[0] { - return FindFieldByJSONTag(t.Field(i).Type, tags[1:]) + if jsonTag == tag { + return FindFieldByJSONTag(t.Field(i).Type, tagRemain) } } return nil diff --git a/pkg/window/policy_test.go b/pkg/window/policy_test.go index a08d1d4ff43..f4ae9989e19 100644 --- a/pkg/window/policy_test.go +++ b/pkg/window/policy_test.go @@ -137,8 +137,8 @@ func TestRollingPolicy_AddWithTimespan(t *testing.T) { t.Logf("%+v", bkt) } - re.Zero(len(policy.window.buckets[0].Points)) + re.Empty(policy.window.buckets[0].Points) re.Equal(4, int(policy.window.buckets[1].Points[0])) - re.Zero(len(policy.window.buckets[2].Points)) + re.Empty(policy.window.buckets[2].Points) }) } diff --git a/server/api/pprof.go b/server/api/pprof.go index bd41a34a6f0..ee4398c60b2 100644 --- a/server/api/pprof.go +++ b/server/api/pprof.go @@ -52,7 +52,7 @@ func newPprofHandler(svr *server.Server, rd *render.Render) *pprofHandler { // @Produce application/octet-stream // @Router /debug/pprof/zip [get] func (h *pprofHandler) PProfZip(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Disposition", fmt.Sprintf(`attachment; filename="pd_debug"`+time.Now().Format("20060102_150405")+".zip")) + w.Header().Set("Content-Disposition", `attachment; filename="pd_debug"`+time.Now().Format("20060102_150405")+".zip") // dump goroutine/heap/mutex items := []struct { diff --git a/server/api/store_test.go b/server/api/store_test.go index 0fb970b42ed..05689333395 100644 --- a/server/api/store_test.go +++ b/server/api/store_test.go @@ -509,7 +509,7 @@ func (suite *storeTestSuite) TestGetAllLimit() { re := suite.Require() for _, testCase := range testCases { - suite.T().Logf(testCase.name) + suite.T().Log(testCase.name) info := make(map[uint64]any, 4) err := tu.ReadGetJSON(re, testDialClient, testCase.url, &info) re.NoError(err) diff --git a/server/forward.go b/server/forward.go index e13f5d45f71..79aea2da119 100644 --- a/server/forward.go +++ b/server/forward.go @@ -131,7 +131,7 @@ func (s *GrpcServer) forwardTSO(stream pdpb.PD_TsoServer) error { } if request.GetCount() == 0 { err = errs.ErrGenerateTimestamp.FastGenByArgs("tso count should be positive") - return status.Errorf(codes.Unknown, err.Error()) + return status.Error(codes.Unknown, err.Error()) } forwardedHost, ok := s.GetServicePrimaryAddr(stream.Context(), constant.TSOServiceName) diff --git a/server/grpc_service.go b/server/grpc_service.go index ab1e9630a5b..9e892dda161 100644 --- a/server/grpc_service.go +++ b/server/grpc_service.go @@ -584,7 +584,7 @@ func (s *GrpcServer) Tso(stream pdpb.PD_TsoServer) error { task.End() tsoHandleDuration.Observe(time.Since(start).Seconds()) if err != nil { - return status.Errorf(codes.Unknown, err.Error()) + return status.Error(codes.Unknown, err.Error()) } response := &pdpb.TsoResponse{ Header: s.header(), diff --git a/tests/integrations/client/client_test.go b/tests/integrations/client/client_test.go index 3c8bba1fafd..9f0b5f8d523 100644 --- a/tests/integrations/client/client_test.go +++ b/tests/integrations/client/client_test.go @@ -594,7 +594,7 @@ func requestGlobalAndLocalTSO( re.Less(localTS, globalTS2) lastTS = globalTS2 } - re.Greater(lastTS, uint64(0)) + re.Positive(lastTS) }(dcLocation) } } @@ -1124,8 +1124,8 @@ func TestCloseClient(t *testing.T) { cli.Close() physical, logical, err := ts.Wait() if err == nil { - re.Greater(physical, int64(0)) - re.Greater(logical, int64(0)) + re.Positive(physical) + re.Positive(logical) } else { re.ErrorIs(err, context.Canceled) re.Zero(physical) diff --git a/tests/integrations/go.mod b/tests/integrations/go.mod index 8b83fdba43d..9e224a339eb 100644 --- a/tests/integrations/go.mod +++ b/tests/integrations/go.mod @@ -1,6 +1,6 @@ module github.com/tikv/pd/tests/integrations -go 1.21 +go 1.23 replace ( github.com/tikv/pd => ../../ @@ -127,7 +127,7 @@ require ( github.com/opentracing/basictracer-go v1.1.0 github.com/opentracing/opentracing-go v1.2.0 github.com/pelletier/go-toml/v2 v2.2.2 // indirect - github.com/petermattis/goid v0.0.0-20211229010228-4d14c490ee36 // indirect + github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 // indirect github.com/phf/go-queue v0.0.0-20170504031614-9abe38d0371d // indirect github.com/pingcap/errcode v0.3.0 // indirect github.com/pingcap/sysutil v1.0.1-0.20230407040306-fb007c5aff21 // indirect @@ -140,7 +140,7 @@ require ( github.com/prometheus/procfs v0.13.0 // indirect github.com/rs/cors v1.7.0 // indirect github.com/samber/lo v1.37.0 // indirect - github.com/sasha-s/go-deadlock v0.2.0 // indirect + github.com/sasha-s/go-deadlock v0.3.5 // indirect github.com/shirou/gopsutil/v3 v3.23.3 // indirect github.com/shoenig/go-m1cpu v0.1.5 // indirect github.com/shurcooL/httpgzip v0.0.0-20190720172056-320755c1c1b0 // indirect diff --git a/tests/integrations/go.sum b/tests/integrations/go.sum index 19cfe26dfc2..8e54c031bd6 100644 --- a/tests/integrations/go.sum +++ b/tests/integrations/go.sum @@ -371,8 +371,8 @@ github.com/pascaldekloe/name v0.0.0-20180628100202-0fd16699aae1/go.mod h1:eD5Jxq github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo= github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= -github.com/petermattis/goid v0.0.0-20211229010228-4d14c490ee36 h1:64bxqeTEN0/xoEqhKGowgihNuzISS9rEG6YUMU4bzJo= -github.com/petermattis/goid v0.0.0-20211229010228-4d14c490ee36/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4= +github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 h1:Dx7Ovyv/SFnMFw3fD4oEoeorXc6saIiQ23LrGLth0Gw= +github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4= github.com/phf/go-queue v0.0.0-20170504031614-9abe38d0371d h1:U+PMnTlV2tu7RuMK5etusZG3Cf+rpow5hqQByeCzJ2g= github.com/phf/go-queue v0.0.0-20170504031614-9abe38d0371d/go.mod h1:lXfE4PvvTW5xOjO6Mba8zDPyw8M93B6AQ7frTGnMlA8= github.com/pingcap/check v0.0.0-20191216031241-8a5a85928f12 h1:rfD9v3+ppLPzoQBgZev0qYCpegrwyFx/BUpkApEiKdY= @@ -428,8 +428,8 @@ github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/samber/lo v1.37.0 h1:XjVcB8g6tgUp8rsPsJ2CvhClfImrpL04YpQHXeHPhRw= github.com/samber/lo v1.37.0/go.mod h1:9vaz2O4o8oOnK23pd2TrXufcbdbJIa3b6cstBWKpopA= -github.com/sasha-s/go-deadlock v0.2.0 h1:lMqc+fUb7RrFS3gQLtoQsJ7/6TV/pAIFvBsqX73DK8Y= -github.com/sasha-s/go-deadlock v0.2.0/go.mod h1:StQn567HiB1fF2yJ44N9au7wOhrPS3iZqiDbRupzT10= +github.com/sasha-s/go-deadlock v0.3.5 h1:tNCOEEDG6tBqrNDOX35j/7hL5FcFViG6awUGROb2NsU= +github.com/sasha-s/go-deadlock v0.3.5/go.mod h1:bugP6EGbdGYObIlx7pUZtWqlvo8k9H6vCBBsiChJQ5U= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/shirou/gopsutil/v3 v3.21.12/go.mod h1:BToYZVTlSVlfazpDDYFnsVZLaoRG+g8ufT6fPQLdJzA= github.com/shirou/gopsutil/v3 v3.23.3 h1:Syt5vVZXUDXPEXpIBt5ziWsJ4LdSAAxF4l/xZeQgSEE= diff --git a/tests/integrations/tso/testutil.go b/tests/integrations/tso/testutil.go index 2a4e5eabd90..ae81f0fbe2b 100644 --- a/tests/integrations/tso/testutil.go +++ b/tests/integrations/tso/testutil.go @@ -34,7 +34,7 @@ type tsoResponse interface { func checkAndReturnTimestampResponse[T tsoResponse](re *require.Assertions, resp T) *pdpb.Timestamp { re.Equal(uint32(tsoCount), resp.GetCount()) timestamp := resp.GetTimestamp() - re.Greater(timestamp.GetPhysical(), int64(0)) + re.Positive(timestamp.GetPhysical()) re.GreaterOrEqual(uint32(timestamp.GetLogical())>>timestamp.GetSuffixBits(), uint32(tsoCount)) return timestamp } diff --git a/tests/server/tso/common_test.go b/tests/server/tso/common_test.go index 877fcb10982..6e6d394f11a 100644 --- a/tests/server/tso/common_test.go +++ b/tests/server/tso/common_test.go @@ -36,7 +36,7 @@ const ( func checkAndReturnTimestampResponse(re *require.Assertions, req *pdpb.TsoRequest, resp *pdpb.TsoResponse) *pdpb.Timestamp { re.Equal(req.GetCount(), resp.GetCount()) timestamp := resp.GetTimestamp() - re.Greater(timestamp.GetPhysical(), int64(0)) + re.Positive(timestamp.GetPhysical()) re.GreaterOrEqual(uint32(timestamp.GetLogical())>>timestamp.GetSuffixBits(), req.GetCount()) return timestamp } diff --git a/tests/tso_cluster.go b/tests/tso_cluster.go index 50495bc4abc..2087e9d4422 100644 --- a/tests/tso_cluster.go +++ b/tests/tso_cluster.go @@ -20,6 +20,7 @@ import ( "sync" "time" + "github.com/pingcap/errors" "github.com/stretchr/testify/require" tso "github.com/tikv/pd/pkg/mcs/tso/server" "github.com/tikv/pd/pkg/mcs/utils/constant" @@ -98,7 +99,7 @@ func RestartTestTSOCluster( }) if err != nil { - return nil, fmt.Errorf("failed to restart the cluster." + err.Error()) + return nil, errors.New("failed to restart the cluster." + err.Error()) } return newCluster, nil diff --git a/tools/go.mod b/tools/go.mod index 14c5c58b7c7..1b1e9dea23f 100644 --- a/tools/go.mod +++ b/tools/go.mod @@ -1,6 +1,6 @@ module github.com/tikv/pd/tools -go 1.21 +go 1.23 replace ( github.com/tikv/pd => ../ @@ -131,7 +131,7 @@ require ( github.com/oleiade/reflections v1.0.1 // indirect github.com/opentracing/opentracing-go v1.2.0 // indirect github.com/pelletier/go-toml/v2 v2.2.2 // indirect - github.com/petermattis/goid v0.0.0-20211229010228-4d14c490ee36 // indirect + github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 // indirect github.com/phf/go-queue v0.0.0-20170504031614-9abe38d0371d // indirect github.com/pingcap/errcode v0.3.0 // indirect github.com/pingcap/sysutil v1.0.1-0.20230407040306-fb007c5aff21 // indirect @@ -144,7 +144,7 @@ require ( github.com/prometheus/procfs v0.13.0 // indirect github.com/rs/cors v1.7.0 // indirect github.com/samber/lo v1.37.0 // indirect - github.com/sasha-s/go-deadlock v0.2.0 // indirect + github.com/sasha-s/go-deadlock v0.3.5 // indirect github.com/shirou/gopsutil/v3 v3.23.3 // indirect github.com/shoenig/go-m1cpu v0.1.5 // indirect github.com/shurcooL/httpgzip v0.0.0-20190720172056-320755c1c1b0 // indirect diff --git a/tools/go.sum b/tools/go.sum index 48bb41289e3..265751b8a05 100644 --- a/tools/go.sum +++ b/tools/go.sum @@ -368,8 +368,8 @@ github.com/pascaldekloe/name v0.0.0-20180628100202-0fd16699aae1/go.mod h1:eD5Jxq github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo= github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= -github.com/petermattis/goid v0.0.0-20211229010228-4d14c490ee36 h1:64bxqeTEN0/xoEqhKGowgihNuzISS9rEG6YUMU4bzJo= -github.com/petermattis/goid v0.0.0-20211229010228-4d14c490ee36/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4= +github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 h1:Dx7Ovyv/SFnMFw3fD4oEoeorXc6saIiQ23LrGLth0Gw= +github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4= github.com/phf/go-queue v0.0.0-20170504031614-9abe38d0371d h1:U+PMnTlV2tu7RuMK5etusZG3Cf+rpow5hqQByeCzJ2g= github.com/phf/go-queue v0.0.0-20170504031614-9abe38d0371d/go.mod h1:lXfE4PvvTW5xOjO6Mba8zDPyw8M93B6AQ7frTGnMlA8= github.com/pingcap/check v0.0.0-20191216031241-8a5a85928f12 h1:rfD9v3+ppLPzoQBgZev0qYCpegrwyFx/BUpkApEiKdY= @@ -427,8 +427,8 @@ github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/samber/lo v1.37.0 h1:XjVcB8g6tgUp8rsPsJ2CvhClfImrpL04YpQHXeHPhRw= github.com/samber/lo v1.37.0/go.mod h1:9vaz2O4o8oOnK23pd2TrXufcbdbJIa3b6cstBWKpopA= -github.com/sasha-s/go-deadlock v0.2.0 h1:lMqc+fUb7RrFS3gQLtoQsJ7/6TV/pAIFvBsqX73DK8Y= -github.com/sasha-s/go-deadlock v0.2.0/go.mod h1:StQn567HiB1fF2yJ44N9au7wOhrPS3iZqiDbRupzT10= +github.com/sasha-s/go-deadlock v0.3.5 h1:tNCOEEDG6tBqrNDOX35j/7hL5FcFViG6awUGROb2NsU= +github.com/sasha-s/go-deadlock v0.3.5/go.mod h1:bugP6EGbdGYObIlx7pUZtWqlvo8k9H6vCBBsiChJQ5U= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/shirou/gopsutil/v3 v3.21.12/go.mod h1:BToYZVTlSVlfazpDDYFnsVZLaoRG+g8ufT6fPQLdJzA= github.com/shirou/gopsutil/v3 v3.23.3 h1:Syt5vVZXUDXPEXpIBt5ziWsJ4LdSAAxF4l/xZeQgSEE= diff --git a/tools/pd-api-bench/README.md b/tools/pd-api-bench/README.md index 76d568b3787..d7dc4c97c09 100644 --- a/tools/pd-api-bench/README.md +++ b/tools/pd-api-bench/README.md @@ -4,7 +4,7 @@ pd-api-bench is a tool to test PD API. ## Build -1. [Go](https://golang.org/) Version 1.21 or later +1. [Go](https://golang.org/) Version 1.23 or later 2. In the root directory of the [PD project](https://github.com/tikv/pd), use the `make pd-api-bench` command to compile and generate `bin/pd-api-bench` ## Usage diff --git a/tools/pd-api-bench/config/config.go b/tools/pd-api-bench/config/config.go index d493479348d..47a02461cfd 100644 --- a/tools/pd-api-bench/config/config.go +++ b/tools/pd-api-bench/config/config.go @@ -96,21 +96,18 @@ func (c *Config) Parse(arguments []string) error { // InitCoordinator set case config from config itself. func (c *Config) InitCoordinator(co *cases.Coordinator) { for name, cfg := range c.HTTP { - cfg := cfg err := co.SetHTTPCase(name, &cfg) if err != nil { log.Error("create HTTP case failed", zap.Error(err)) } } for name, cfg := range c.GRPC { - cfg := cfg err := co.SetGRPCCase(name, &cfg) if err != nil { log.Error("create gRPC case failed", zap.Error(err)) } } for name, cfg := range c.Etcd { - cfg := cfg err := co.SetEtcdCase(name, &cfg) if err != nil { log.Error("create etcd case failed", zap.Error(err)) diff --git a/tools/pd-api-bench/main.go b/tools/pd-api-bench/main.go index f642ede0069..b30b21aab1d 100644 --- a/tools/pd-api-bench/main.go +++ b/tools/pd-api-bench/main.go @@ -255,7 +255,6 @@ func runHTTPServer(cfg *config.Config, co *cases.Coordinator) { return } for name, cfg := range input { - cfg := cfg co.SetHTTPCase(name, &cfg) } c.String(http.StatusOK, "") @@ -273,7 +272,6 @@ func runHTTPServer(cfg *config.Config, co *cases.Coordinator) { return } for name, cfg := range input { - cfg := cfg co.SetGRPCCase(name, &cfg) } c.String(http.StatusOK, "") @@ -291,7 +289,6 @@ func runHTTPServer(cfg *config.Config, co *cases.Coordinator) { return } for name, cfg := range input { - cfg := cfg co.SetEtcdCase(name, &cfg) } c.String(http.StatusOK, "") diff --git a/tools/pd-ctl/README.md b/tools/pd-ctl/README.md index 072ef61cb34..25f7b5d629c 100644 --- a/tools/pd-ctl/README.md +++ b/tools/pd-ctl/README.md @@ -4,7 +4,7 @@ ## Build -1. [Go](https://golang.org/) Version 1.21 or later +1. [Go](https://golang.org/) Version 1.23 or later 2. In the root directory of the [PD project](https://github.com/tikv/pd), use the `make pd-ctl` command to compile and generate `bin/pd-ctl`. ## Usage diff --git a/tools/pd-recover/README.md b/tools/pd-recover/README.md index fe5b6208d44..f2178ee966a 100644 --- a/tools/pd-recover/README.md +++ b/tools/pd-recover/README.md @@ -4,7 +4,7 @@ ## Build -1. [Go](https://golang.org/) Version 1.21 or later +1. [Go](https://golang.org/) Version 1.23 or later 2. In the root directory of the [PD project](https://github.com/tikv/pd), use the `make pd-recover` command to compile and generate `bin/pd-recover`. ## Usage diff --git a/tools/pd-simulator/README.md b/tools/pd-simulator/README.md index 1dc623c7fdd..55494d2333e 100644 --- a/tools/pd-simulator/README.md +++ b/tools/pd-simulator/README.md @@ -4,7 +4,7 @@ pd-simulator is a tool to reproduce some scenarios and evaluate the schedulers' ## Build -1. [Go](https://golang.org/) Version 1.21 or later +1. [Go](https://golang.org/) Version 1.23 or later 2. In the root directory of the [PD project](https://github.com/tikv/pd), use the `make simulator` command to compile and generate `bin/pd-simulator` ## Usage diff --git a/tools/pd-tso-bench/README.md b/tools/pd-tso-bench/README.md index df0126d5203..5eb94390546 100644 --- a/tools/pd-tso-bench/README.md +++ b/tools/pd-tso-bench/README.md @@ -4,7 +4,7 @@ pd-tso-bench is a tool to benchmark GetTS performance. ## Build -1. [Go](https://golang.org/) Version 1.21 or later +1. [Go](https://golang.org/) Version 1.23 or later 2. In the root directory of the [PD project](https://github.com/tikv/pd), use the `make` command to compile and generate `bin/pd-tso-bench` ## Usage diff --git a/tools/pd-ut/README.md b/tools/pd-ut/README.md index 805ee5cf322..f76a27732f7 100644 --- a/tools/pd-ut/README.md +++ b/tools/pd-ut/README.md @@ -4,7 +4,7 @@ pd-ut is a tool to run unit tests for PD. ## Build -1. [Go](https://golang.org/) Version 1.21 or later +1. [Go](https://golang.org/) Version 1.23 or later 2. In the root directory of the [PD project](https://github.com/tikv/pd), use the `make pd-ut` command to compile and generate `bin/pd-ut` ## Usage