* support set assertion in 2pc mutation Signed-off-by: lysu <sulifx@gmail.com> Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com> * Receive assertion fail errors from TiKV Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com> * Add test log Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com> * Remove verbose log Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com> * update kvproto Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com> * Add metrics counter for assertions Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com> * Address some comments Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com> * Try to optimize assertion for pessimistic transactions Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com> * Fix panic on optimistic transactions Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com> * Add InitCheckExistence method for LockCtx Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com> * Support assertion level Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com> * Check assertion level before doing assertion on client side Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com> * Test bitoperations of menBUfferMutations.Push Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com> * Add test for assertion in tikv Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com> * Support run assertion test with unistore Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com> * Fix test Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com> * Fix license Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com> * Fix test Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com> * export DeleteKey Signed-off-by: ekexium <ekexium@gmail.com> * Renaming DeleteKey Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com> * fix build Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com> * Address comments Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com> * Avoid panic when running with old version of TiKV; Add schema check on fast assertion Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com> * Add test for fast assertion Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com> * Add test for pessimistic lock check existence Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com> * Test assertion takes no effect if amending is enabled Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com> * Add HasAssertUnknown function Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com> * Add comments Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com> * Cleanup locks after assertion fail Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com> * update tidb dependency Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com> * Fix panic in TestIllegalTSO Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com> * Address comments Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com> * Add comments Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com> * Update dependency to tidb Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com> * Fix test Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com> Co-authored-by: lysu <sulifx@gmail.com> Co-authored-by: MyonKeminta <MyonKeminta@users.noreply.github.com> Co-authored-by: ekexium <ekexium@gmail.com> |
||
|---|---|---|
| .github | ||
| config | ||
| error | ||
| examples | ||
| integration_tests | ||
| internal | ||
| kv | ||
| metrics | ||
| oracle | ||
| rawkv | ||
| testutils | ||
| tikv | ||
| tikvrpc | ||
| txnkv | ||
| util | ||
| .gitignore | ||
| .golangci.yml | ||
| CONTRIBUTING.md | ||
| LICENSE | ||
| README.md | ||
| go.mod | ||
| go.sum | ||
README.md
TiKV Go Client
TiKV Go Client provides support for interacting with the TiKV server in the form of a Go library.
Package versions
There are 2 major versions of the client-go package.
-
v2is the new active version. This version was extracted from pingcap/tidb and it includes new TiKV features like Follower Read, 1PC, Async Commit. The development of this version is on themasterbranch. The documentation for this version is below. -
v1is the previous stable version and is only maintained for bug fixes. You can read the documentation here.
- 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.
Usage/Examples
go get github.com/tikv/client-go/v2@COMMIT_HASH_OR_TAG_VERSION
More examples can be found in examples directory.
Contributing to client-go
Pull Requests and issues are welcomed. Please check CONTRIBUTING.md.
Developing
Running Tests
Note: All the following tests are included in the CI and you can submit a Pull Request directly to hand over the work.
To run unit tests, use following command
go test ./...
To run code linter, make sure golangci-lint is installed. Then use following command
golangci-lint run
integration_tests can run against a real TiKV cluster. Here is an example:
./pd-server &
sleep 5
./tikv-server &
sleep 10
cd integration_tests
go test --with-tikv
Test with TiDB
It is a common task to update client-go and then test it with TiDB.
If you only need to test locally, you can directly use the modified client-go on the same host by replacing:
go mod edit -replace=github.com/tikv/client-go/v2=/path/to/client-go
If you want to push your TiDB code to GitHub for running CI or for code review, you need to change the client-go used by TiDB to your developing branch using the following steps:
go get -d github.com/GITHUB_USERNAME/client-go/v2@DEV_BRANCH
# Output:
# go get: github.com/GITHUB_USERNAME/client-go/v2@none updating to
# github.com/GITHUB_USERNAME/client-go/v2@v2.0.0-XXXXXXXXXXXXXX-XXXXXXXXXXXX: parsing go.mod:
# module declares its path as: github.com/tikv/client-go/v2
# but was required as: github.com/GITHUB_USERNAME/client-go/v2
go mod edit -replace=github.com/tikv/client-go/v2=github.com/GITHUB_USERNAME/client-go/v2@v2.0.0-XXXXXXXXXXXXXX-XXXXXXXXXXXX
go mod download github.com/tikv/client-go/v2
Used By
client-go is used by the following projects:
- TiDB: TiDB is an open source distributed HTAP database compatible with the MySQL protocol
- BR: A command-line tool for distributed backup and restoration of the TiDB cluster data
- TiCDC: Change data capture for TiDB
- go-ycsb: A Go port of Yahoo! Cloud Serving Benchmark (YCSB)
- JuiceFS: JuiceFS is a distributed POSIX file system built on top of Redis and S3