Skip to content

Commit 5500e19

Browse files
committed
Merge branch 'master' into sa-master-v2
2 parents bbd8a5a + 8c3f29a commit 5500e19

File tree

199 files changed

+6526
-2731
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

199 files changed

+6526
-2731
lines changed

.github/workflows/compatibility.yml

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -34,35 +34,6 @@ jobs:
3434
make server
3535
working-directory: tidb
3636

37-
- name: Checkout BR
38-
uses: actions/checkout@v2
39-
with:
40-
repository: pingcap/br
41-
path: br
42-
43-
- name: Check build
44-
run: |
45-
cp go.mod1 go.mod && cp go.sum1 go.sum
46-
go mod edit -replace=github.com/tikv/client-go/v2=../client-go
47-
go mod edit -replace=github.com/pingcap/tidb=../tidb
48-
go mod tidy
49-
go build ./...
50-
working-directory: br
51-
52-
- name: Checkout TiCDC
53-
uses: actions/checkout@v2
54-
with:
55-
repository: pingcap/ticdc
56-
path: ticdc
57-
58-
- name: Check build
59-
run: |
60-
go mod edit -replace=github.com/tikv/client-go/v2=../client-go
61-
go mod edit -replace=github.com/pingcap/tidb=../tidb
62-
go mod tidy
63-
make
64-
working-directory: ticdc
65-
6637
- name: Checkout go-ycsb
6738
uses: actions/checkout@v2
6839
with:

.github/workflows/integration.yml

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
go-version: 1.16
2121

2222
- name: Test
23-
run: go test
23+
run: go test ./...
2424
working-directory: integration_tests
2525

2626
integration-local-race:
@@ -35,7 +35,7 @@ jobs:
3535
go-version: 1.16
3636

3737
- name: Test
38-
run: go test -race
38+
run: go test ./... -race
3939
working-directory: integration_tests
4040

4141
integration-tikv:
@@ -77,3 +77,41 @@ jobs:
7777
run: go test --with-tikv
7878
working-directory: integration_tests
7979

80+
integration-raw-tikv:
81+
runs-on: ubuntu-latest
82+
steps:
83+
- name: Checkout
84+
uses: actions/checkout@v2
85+
86+
- name: Set up Go
87+
uses: actions/setup-go@v2
88+
with:
89+
go-version: 1.16
90+
91+
- name: Fetch PD
92+
uses: shrink/actions-docker-extract@v1
93+
id: extract-pd
94+
with:
95+
image: pingcap/pd:nightly
96+
path: /pd-server
97+
98+
- name: Fetch TiKV
99+
uses: shrink/actions-docker-extract@v1
100+
id: extract-tikv
101+
with:
102+
image: pingcap/tikv:nightly
103+
path: /tikv-server
104+
105+
- name: Run PD & TiKV
106+
run: |
107+
mv ../../${{steps.extract-pd.outputs.destination}}/pd-server .
108+
mv ../../${{steps.extract-tikv.outputs.destination}}/tikv-server .
109+
./pd-server > pd.log 2>&1 &
110+
sleep 5
111+
./tikv-server -C tikv.toml > tikv.log 2>&1 &
112+
sleep 15
113+
working-directory: integration_tests/raw
114+
115+
- name: Test
116+
run: go test --with-tikv
117+
working-directory: integration_tests/raw

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- name: Set up Go
1616
uses: actions/setup-go@v2
1717
with:
18-
go-version: 1.15
18+
go-version: 1.16
1919

2020
- name: Test
2121
run: go test ./...
@@ -28,7 +28,7 @@ jobs:
2828
- name: Set up Go
2929
uses: actions/setup-go@v2
3030
with:
31-
go-version: 1.15
31+
go-version: 1.16
3232

3333
- name: Test with race
3434
run: go test -race ./...
@@ -42,7 +42,7 @@ jobs:
4242
- name: Set up Go
4343
uses: actions/setup-go@v2
4444
with:
45-
go-version: 1.15
45+
go-version: 1.16
4646

4747
- name: Lint
4848
uses: golangci/golangci-lint-action@v2

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
vendor
22
.idea
3+
.vscode

README.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,22 @@ TiKV Go Client provides support for interacting with the [TiKV](https://github.c
99
[![Integration Test](https://github.com/tikv/client-go/actions/workflows/integration.yml/badge.svg)](https://github.com/tikv/client-go/actions/workflows/integration.yml)
1010
[![Compatibility Test](https://github.com/tikv/client-go/actions/workflows/compatibility.yml/badge.svg)](https://github.com/tikv/client-go/actions/workflows/compatibility.yml)
1111

12-
1312
## Package versions
1413

1514
There are 2 major versions of the `client-go` package.
1615

17-
- `v2` is the new active version. This version was extracted from [pingcap/tidb](https://github.com/pingcap/tidb) and it includes new TiKV features like Follower Read, 1PC, Async Commit. The development of this version is on the `master` branch. The documentation for this version is below.
16+
- `v2` is the latest stable version. This version was extracted from [pingcap/tidb](https://github.com/pingcap/tidb) and it includes new TiKV features like Follower Read, 1PC, Async Commit. The development of this version is on the `master` branch. The documentation for this version is below.
1817

1918
- `v1` is the previous stable version and is only maintained for bug fixes. You can read the documentation [here](https://tikv.org/docs/4.0/reference/clients/go/).
2019

21-
```diff
22-
- warning: The v2 branch is still being refactored and sorted out, and external interfaces may change before the v2.0.0 release. Please use caution in production environments.
23-
```
24-
2520
## Usage/Examples
2621

2722
```bash
23+
# valid versions be like @latest, @e5f932ae270887550b0cd221343dbd6b870b6c8f, @v2.0.0, @v2.0.1...
2824
go get github.com/tikv/client-go/v2@COMMIT_HASH_OR_TAG_VERSION
2925
```
3026

31-
More examples can be found in [examples directory](https://github.com/tikv/client-go/tree/master/examples).
27+
Explanation of related concepts and sample code can be found in the [Client-Go Wiki](https://github.com/tikv/client-go/wiki). There are also executable examples in [examples directory](https://github.com/tikv/client-go/tree/master/examples).
3228

3329
## Contributing to client-go
3430

config/client.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
//
99
// Unless required by applicable law or agreed to in writing, software
1010
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1112
// See the License for the specific language governing permissions and
1213
// limitations under the License.
1314

@@ -27,6 +28,7 @@
2728
//
2829
// Unless required by applicable law or agreed to in writing, software
2930
// distributed under the License is distributed on an "AS IS" BASIS,
31+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3032
// See the License for the specific language governing permissions and
3133
// limitations under the License.
3234

@@ -80,7 +82,8 @@ type TiKVClient struct {
8082
StoreLivenessTimeout string `toml:"store-liveness-timeout" json:"store-liveness-timeout"`
8183
CoprCache CoprocessorCache `toml:"copr-cache" json:"copr-cache"`
8284
// TTLRefreshedTxnSize controls whether a transaction should update its TTL or not.
83-
TTLRefreshedTxnSize int64 `toml:"ttl-refreshed-txn-size" json:"ttl-refreshed-txn-size"`
85+
TTLRefreshedTxnSize int64 `toml:"ttl-refreshed-txn-size" json:"ttl-refreshed-txn-size"`
86+
ResolveLockLiteThreshold uint64 `toml:"resolve-lock-lite-threshold" json:"resolve-lock-lite-threshold"`
8487
}
8588

8689
// AsyncCommit is the config for the async commit feature. The switch to enable it is a system variable.
@@ -147,6 +150,8 @@ func DefaultTiKVClient() TiKVClient {
147150
AdmissionMaxResultMB: 10,
148151
AdmissionMinProcessMs: 5,
149152
},
153+
154+
ResolveLockLiteThreshold: 16,
150155
}
151156
}
152157

config/config.go

Lines changed: 4 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
//
99
// Unless required by applicable law or agreed to in writing, software
1010
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1112
// See the License for the specific language governing permissions and
1213
// limitations under the License.
1314

@@ -27,20 +28,19 @@
2728
//
2829
// Unless required by applicable law or agreed to in writing, software
2930
// distributed under the License is distributed on an "AS IS" BASIS,
31+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3032
// See the License for the specific language governing permissions and
3133
// limitations under the License.
3234

3335
package config
3436

3537
import (
3638
"fmt"
37-
"net/http"
3839
"net/url"
3940
"strings"
40-
"sync"
4141
"sync/atomic"
4242

43-
"github.com/pingcap/errors"
43+
"github.com/pkg/errors"
4444
"github.com/tikv/client-go/v2/internal/logutil"
4545
"github.com/tikv/client-go/v2/oracle"
4646
"github.com/tikv/client-go/v2/util"
@@ -184,7 +184,7 @@ func ParsePath(path string) (etcdAddrs []string, disableGC bool, err error) {
184184
var u *url.URL
185185
u, err = url.Parse(path)
186186
if err != nil {
187-
err = errors.Trace(err)
187+
err = errors.WithStack(err)
188188
return
189189
}
190190
if strings.ToLower(u.Scheme) != "tikv" {
@@ -203,38 +203,3 @@ func ParsePath(path string) (etcdAddrs []string, disableGC bool, err error) {
203203
etcdAddrs = strings.Split(u.Host, ",")
204204
return
205205
}
206-
207-
var (
208-
internalClientInit sync.Once
209-
internalHTTPClient *http.Client
210-
internalHTTPSchema string
211-
)
212-
213-
// InternalHTTPClient is used by TiDB-Server to request other components.
214-
func InternalHTTPClient() *http.Client {
215-
internalClientInit.Do(initInternalClient)
216-
return internalHTTPClient
217-
}
218-
219-
// InternalHTTPSchema specifies use http or https to request other components.
220-
func InternalHTTPSchema() string {
221-
internalClientInit.Do(initInternalClient)
222-
return internalHTTPSchema
223-
}
224-
225-
func initInternalClient() {
226-
clusterSecurity := GetGlobalConfig().Security
227-
tlsCfg, err := clusterSecurity.ToTLSConfig()
228-
if err != nil {
229-
logutil.BgLogger().Fatal("could not load cluster ssl", zap.Error(err))
230-
}
231-
if tlsCfg == nil {
232-
internalHTTPSchema = "http"
233-
internalHTTPClient = http.DefaultClient
234-
return
235-
}
236-
internalHTTPSchema = "https"
237-
internalHTTPClient = &http.Client{
238-
Transport: &http.Transport{TLSClientConfig: tlsCfg},
239-
}
240-
}

config/config_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
//
99
// Unless required by applicable law or agreed to in writing, software
1010
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1112
// See the License for the specific language governing permissions and
1213
// limitations under the License.
1314

@@ -27,6 +28,7 @@
2728
//
2829
// Unless required by applicable law or agreed to in writing, software
2930
// distributed under the License is distributed on an "AS IS" BASIS,
31+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3032
// See the License for the specific language governing permissions and
3133
// limitations under the License.
3234

config/main_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
//
99
// Unless required by applicable law or agreed to in writing, software
1010
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1112
// See the License for the specific language governing permissions and
1213
// limitations under the License.
1314

config/security.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
//
99
// Unless required by applicable law or agreed to in writing, software
1010
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1112
// See the License for the specific language governing permissions and
1213
// limitations under the License.
1314

@@ -27,6 +28,7 @@
2728
//
2829
// Unless required by applicable law or agreed to in writing, software
2930
// distributed under the License is distributed on an "AS IS" BASIS,
31+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3032
// See the License for the specific language governing permissions and
3133
// limitations under the License.
3234

@@ -35,9 +37,9 @@ package config
3537
import (
3638
"crypto/tls"
3739
"crypto/x509"
38-
"io/ioutil"
40+
"os"
3941

40-
"github.com/pingcap/errors"
42+
"github.com/pkg/errors"
4143
)
4244

4345
// Security is the security section of the config.
@@ -64,7 +66,7 @@ func (s *Security) ToTLSConfig() (tlsConfig *tls.Config, err error) {
6466
certPool := x509.NewCertPool()
6567
// Create a certificate pool from the certificate authority
6668
var ca []byte
67-
ca, err = ioutil.ReadFile(s.ClusterSSLCA)
69+
ca, err = os.ReadFile(s.ClusterSSLCA)
6870
if err != nil {
6971
err = errors.Errorf("could not read ca certificate: %s", err)
7072
return

0 commit comments

Comments
 (0)