titan icon indicating copy to clipboard operation
titan copied to clipboard

feat: upgrade tikv-client to v2.0.7 and remove legacy dependencies

Open donbowman opened this issue 1 month ago • 0 comments

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:

  1. Dependency Management:

    • Upgraded github.com/tikv/client-go/v2 to v2.0.7.
    • Removed all dependencies on github.com/pingcap/tidb.
    • Updated go.etcd.io/etcd imports to go.etcd.io/etcd/client/v3 (v3.5.x).
    • Added replace directives in go.mod for bbolt and gofail to resolve transitive dependency conflicts.
    • Ran go mod tidy to clean up the module graph.
  2. Storage Layer (db/store):

    • Refactored Storage interface to align with client-go v2 API (e.g., CurrentVersion -> CurrentTimestamp).
    • Updated Transaction type alias to *txnkv.KVTxn.
    • Explicitly defined Iterator interface as it is no longer exported directly by the upstream package.
    • Updated error handling to use github.com/tikv/client-go/v2/error (aliased as tikverr).
    • Updated transaction options to use txnutil priorities.
  3. 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 with bytes.HasPrefix().
    • Updated tikvgc.go to use the new CurrentTimestamp API for GC safe point calculations.
  4. Testing Infrastructure:

    • Rewrote db/store/mock_store.go to use github.com/tikv/client-go/v2/testutils.
    • Added bootstrapping logic (BootstrapWithSingleStore) to MockOpen to ensure regions are initialized for tests.
    • Removed heavy go.etcd.io/etcd/integration dependencies from command/test_test.go and tools/autotest/main_test.go, significantly reducing build complexity and test startup time.
    • Refactored db/gc_test.go to remove legacy tidb/kv imports and use local helper functions.
  5. Tools:

    • Updated tools/expire/main.go to use the correct store.Transaction interface and remove unused imports.
    • Updated db/task.go to use the modern etcd client import path.
  6. Deployment & Environment:

    • Updated docker-compose.yml to the latest specification (removed version field) and enabled local build context.
    • Add docker-compose-3-node.yml to configure a full 3-node PD and 3-node TiKV cluster with unique volume mounts for data isolation.
  7. Transaction retry/backoff hardening

donbowman avatar Nov 23 '25 23:11 donbowman