titan
titan copied to clipboard
feat: upgrade tikv-client to v2.0.7 and remove legacy dependencies
This commit completes the migration from the legacy
github.com/pingcap/tidb kv client to the modern
github.com/tikv/client-go/v2. It also cleans up dependencies, fixes
build issues, and updates the testing infrastructure.
Key Changes:
-
Dependency Management:
- Upgraded
github.com/tikv/client-go/v2tov2.0.7. - Removed all dependencies on
github.com/pingcap/tidb. - Updated
go.etcd.io/etcdimports togo.etcd.io/etcd/client/v3(v3.5.x). - Added
replacedirectives ingo.modforbboltandgofailto resolve transitive dependency conflicts. - Ran
go mod tidyto clean up the module graph.
- Upgraded
-
Storage Layer (
db/store):- Refactored
Storageinterface to align withclient-gov2 API (e.g.,CurrentVersion->CurrentTimestamp). - Updated
Transactiontype alias to*txnkv.KVTxn. - Explicitly defined
Iteratorinterface as it is no longer exported directly by the upstream package. - Updated error handling to use
github.com/tikv/client-go/v2/error(aliased astikverr). - Updated transaction options to use
txnutilpriorities.
- Refactored
-
Core Logic (
db/):- Updated
db.go,kv.go, and data structure implementations (hash.go,set.go,zset.go,llist.go) to handle API changes. - Replaced usage of
kv.Key(type alias) with standard[]byte. - Replaced
key.HasPrefix()helper calls withbytes.HasPrefix(). - Updated
tikvgc.goto use the newCurrentTimestampAPI for GC safe point calculations.
- Updated
-
Testing Infrastructure:
- Rewrote
db/store/mock_store.goto usegithub.com/tikv/client-go/v2/testutils. - Added bootstrapping logic (
BootstrapWithSingleStore) toMockOpento ensure regions are initialized for tests. - Removed heavy
go.etcd.io/etcd/integrationdependencies fromcommand/test_test.goandtools/autotest/main_test.go, significantly reducing build complexity and test startup time. - Refactored
db/gc_test.goto remove legacytidb/kvimports and use local helper functions.
- Rewrote
-
Tools:
- Updated
tools/expire/main.goto use the correctstore.Transactioninterface and remove unused imports. - Updated
db/task.goto use the modern etcd client import path.
- Updated
-
Deployment & Environment:
- Updated
docker-compose.ymlto the latest specification (removed version field) and enabled local build context. - Add
docker-compose-3-node.ymlto configure a full 3-node PD and 3-node TiKV cluster with unique volume mounts for data isolation.
- Updated
-
Transaction retry/backoff hardening