Skip to content

Commit 9141476

Browse files
committed
Merge branch 'master' into sa-master-v2
2 parents 5500e19 + ad59ca8 commit 9141476

File tree

108 files changed

+6676
-1675
lines changed

Some content is hidden

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

108 files changed

+6676
-1675
lines changed

.github/workflows/compatibility.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- name: Set up Go
1515
uses: actions/setup-go@v2
1616
with:
17-
go-version: 1.16
17+
go-version: 1.19
1818

1919
- name: Checkout Client-Go
2020
uses: actions/checkout@v2

.github/workflows/integration.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Set up Go
1818
uses: actions/setup-go@v2
1919
with:
20-
go-version: 1.16
20+
go-version: 1.19
2121

2222
- name: Test
2323
run: go test ./...
@@ -32,7 +32,7 @@ jobs:
3232
- name: Set up Go
3333
uses: actions/setup-go@v2
3434
with:
35-
go-version: 1.16
35+
go-version: 1.19
3636

3737
- name: Test
3838
run: go test ./... -race
@@ -47,7 +47,7 @@ jobs:
4747
- name: Set up Go
4848
uses: actions/setup-go@v2
4949
with:
50-
go-version: 1.16
50+
go-version: 1.19
5151

5252
- name: Fetch PD
5353
uses: shrink/actions-docker-extract@v1
@@ -79,14 +79,17 @@ jobs:
7979

8080
integration-raw-tikv:
8181
runs-on: ubuntu-latest
82+
strategy:
83+
matrix:
84+
api_version: [v1ttl, v2]
8285
steps:
8386
- name: Checkout
8487
uses: actions/checkout@v2
8588

8689
- name: Set up Go
8790
uses: actions/setup-go@v2
8891
with:
89-
go-version: 1.16
92+
go-version: 1.19
9093

9194
- name: Fetch PD
9295
uses: shrink/actions-docker-extract@v1
@@ -108,7 +111,7 @@ jobs:
108111
mv ../../${{steps.extract-tikv.outputs.destination}}/tikv-server .
109112
./pd-server > pd.log 2>&1 &
110113
sleep 5
111-
./tikv-server -C tikv.toml > tikv.log 2>&1 &
114+
./tikv-server -C tikv-${{ matrix.api_version }}.toml > tikv.log 2>&1 &
112115
sleep 15
113116
working-directory: integration_tests/raw
114117

.github/workflows/test.yml

Lines changed: 6 additions & 5 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.16
18+
go-version: 1.18
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.16
31+
go-version: 1.18
3232

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

4747
- name: Lint
48-
uses: golangci/golangci-lint-action@v2
48+
uses: golangci/golangci-lint-action@v2.5.2
4949
with:
50-
version: v1.29
50+
version: v1.47.3
51+

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ go mod download github.com/tikv/client-go/v2
9191
- [TiCDC](https://github.com/pingcap/ticdc): Change data capture for TiDB
9292
- [go-ycsb](https://github.com/pingcap/go-ycsb): A Go port of Yahoo! Cloud Serving Benchmark (YCSB)
9393
- [JuiceFS](https://github.com/juicedata/juicefs): JuiceFS is a distributed POSIX file system built on top of Redis and S3
94+
- [tcli](https://github.com/c4pt0r/tcli): A CLI tool for TiKV, for human being :)
9495

9596
## License
9697

error/error.go

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
package error
3636

3737
import (
38+
"encoding/hex"
3839
"fmt"
3940
"time"
4041

@@ -86,6 +87,12 @@ var (
8687
ErrRegionNotInitialized = errors.New("region not Initialized")
8788
// ErrTiKVDiskFull is the error when tikv server disk usage is full.
8889
ErrTiKVDiskFull = errors.New("tikv disk full")
90+
// ErrRegionRecoveryInProgress is the error when region is recovering.
91+
ErrRegionRecoveryInProgress = errors.New("region is being online unsafe recovered")
92+
// ErrRegionFlashbackInProgress is the error when a region in the flashback progress receive any other request.
93+
ErrRegionFlashbackInProgress = errors.New("region is in the flashback progress")
94+
// ErrRegionFlashbackNotPrepared is the error when a region is not prepared for the flashback first.
95+
ErrRegionFlashbackNotPrepared = errors.New("region is not prepared for the flashback")
8996
// ErrUnknown is the unknow error.
9097
ErrUnknown = errors.New("unknow")
9198
// ErrResultUndetermined is the error when execution result is unknown.
@@ -150,13 +157,14 @@ func IsErrWriteConflict(err error) bool {
150157
return errors.As(err, &e)
151158
}
152159

153-
//NewErrWriteConfictWithArgs generates an ErrWriteConflict with args.
154-
func NewErrWriteConfictWithArgs(startTs, conflictTs, conflictCommitTs uint64, key []byte) *ErrWriteConflict {
160+
// NewErrWriteConflictWithArgs generates an ErrWriteConflict with args.
161+
func NewErrWriteConflictWithArgs(startTs, conflictTs, conflictCommitTs uint64, key []byte, reason kvrpcpb.WriteConflict_Reason) *ErrWriteConflict {
155162
conflict := kvrpcpb.WriteConflict{
156163
StartTs: startTs,
157164
ConflictTs: conflictTs,
158165
Key: key,
159166
ConflictCommitTs: conflictCommitTs,
167+
Reason: reason,
160168
}
161169
return &ErrWriteConflict{WriteConflict: &conflict}
162170
}
@@ -236,10 +244,36 @@ type ErrAssertionFailed struct {
236244
*kvrpcpb.AssertionFailed
237245
}
238246

247+
// ErrLockOnlyIfExistsNoReturnValue is used when the flag `LockOnlyIfExists` of `LockCtx` is set, but `ReturnValues`` is not.
248+
type ErrLockOnlyIfExistsNoReturnValue struct {
249+
StartTS uint64
250+
ForUpdateTs uint64
251+
LockKey []byte
252+
}
253+
254+
// ErrLockOnlyIfExistsNoPrimaryKey is used when the flag `LockOnlyIfExists` of `LockCtx` is set, but primary key of current transaction is not.
255+
type ErrLockOnlyIfExistsNoPrimaryKey struct {
256+
StartTS uint64
257+
ForUpdateTs uint64
258+
LockKey []byte
259+
}
260+
239261
func (e *ErrAssertionFailed) Error() string {
240262
return fmt.Sprintf("assertion failed { %s }", e.AssertionFailed.String())
241263
}
242264

265+
func (e *ErrLockOnlyIfExistsNoReturnValue) Error() string {
266+
return fmt.Sprintf("LockOnlyIfExists is set for Lock Context, but ReturnValues is not set, "+
267+
"StartTs is {%d}, ForUpdateTs is {%d}, one of lock keys is {%v}.",
268+
e.StartTS, e.ForUpdateTs, hex.EncodeToString(e.LockKey))
269+
}
270+
271+
func (e *ErrLockOnlyIfExistsNoPrimaryKey) Error() string {
272+
return fmt.Sprintf("LockOnlyIfExists is set for Lock Context, but primary key of current transaction is not set, "+
273+
"StartTs is {%d}, ForUpdateTs is {%d}, one of lock keys is {%s}",
274+
e.StartTS, e.ForUpdateTs, hex.EncodeToString(e.LockKey))
275+
}
276+
243277
// ExtractKeyErr extracts a KeyError.
244278
func ExtractKeyErr(keyErr *kvrpcpb.KeyError) error {
245279
if val, err := util.EvalFailpoint("mockRetryableErrorResp"); err == nil {

examples/gcworker/gcworker.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"time"
2222

2323
"github.com/tikv/client-go/v2/oracle"
24-
"github.com/tikv/client-go/v2/tikv"
24+
"github.com/tikv/client-go/v2/txnkv"
2525
)
2626

2727
var (
@@ -31,7 +31,7 @@ var (
3131

3232
func main() {
3333
flag.Parse()
34-
client, err := tikv.NewTxnClient([]string{*pdAddr})
34+
client, err := txnkv.NewClient([]string{*pdAddr})
3535
if err != nil {
3636
panic(err)
3737
}

examples/gcworker/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module gcworker
22

3-
go 1.16
3+
go 1.18
44

55
require github.com/tikv/client-go/v2 v2.0.0
66

examples/rawkv/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module rawkv
22

3-
go 1.16
3+
go 1.18
44

55
require github.com/tikv/client-go/v2 v2.0.0
66

examples/txnkv/1pc_txn/1pc_txn.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,18 @@ import (
2020
"fmt"
2121
"os"
2222

23-
"github.com/tikv/client-go/v2/tikv"
23+
"github.com/tikv/client-go/v2/txnkv"
2424
)
2525

2626
var (
27-
client *tikv.KVStore
27+
client *txnkv.Client
2828
pdAddr = flag.String("pd", "127.0.0.1:2379", "pd address")
2929
)
3030

3131
// Init initializes information.
3232
func initStore() {
3333
var err error
34-
client, err = tikv.NewTxnClient([]string{*pdAddr})
34+
client, err = txnkv.NewClient([]string{*pdAddr})
3535
if err != nil {
3636
panic(err)
3737
}

examples/txnkv/1pc_txn/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module 1pc_txn
22

3-
go 1.16
3+
go 1.18
44

55
require github.com/tikv/client-go/v2 v2.0.0
66

0 commit comments

Comments
 (0)