Skip to content

feat(tikv): add keyspace API V2 support#1

Open
IANTHEREAL wants to merge 4 commits into
mainfrom
feat/tikv-keyspace-api-v2
Open

feat(tikv): add keyspace API V2 support#1
IANTHEREAL wants to merge 4 commits into
mainfrom
feat/tikv-keyspace-api-v2

Conversation

@IANTHEREAL

Copy link
Copy Markdown

Summary

Add ?keyspace=<name> URL parameter support for TiKV metadata backend. When present, the client uses TiKV API V2 with per-keyspace isolation.

This enables the FS V3.5 per-tenant volume architecture where each tenant's JuiceFS metadata is isolated in its own TiKV keyspace.

Usage

# With keyspace (API V2, per-tenant isolation):
tikv://pd:2379?keyspace=jfs_t_tenant1

# With keyspace + TLS:
tikv://pd:2379?keyspace=jfs_t_tenant1&ca=/tls/ca.crt&cert=/tls/tls.crt&key=/tls/tls.key

# Without keyspace (unchanged, default keyspace, API V1):
tikv://pd:2379

Change

11 lines in pkg/meta/tkv_tikv.go — passes txnkv.WithKeyspace() + txnkv.WithAPIVersion(V2) to txnkv.NewClient() when keyspace parameter is present.

Test plan

  • juicefs format tikv://pd:2379?keyspace=test_ks ... creates volume in isolated keyspace
  • juicefs mount tikv://pd:2379?keyspace=test_ks ... mounts successfully
  • Without ?keyspace=, existing behavior unchanged
  • With TLS params (ca=, cert=, key=) + keyspace, both work together

🤖 Generated with Claude Code

IANTHEREAL and others added 4 commits April 11, 2026 20:45
When `?keyspace=<name>` is present in the TiKV meta URL, the client
uses API V2 with the specified keyspace. This enables per-tenant
metadata isolation on shared TiKV clusters.

Usage:
  tikv://pd:2379?keyspace=jfs_t_tenant1
  tikv://pd:2379?keyspace=jfs_t_tenant1&ca=/tls/ca.crt&cert=/tls/tls.crt&key=/tls/tls.key

Without `?keyspace=`, behavior is unchanged (default keyspace, API V1).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Used after TiKV BR clone to prevent slice ID collision between
original and cloned volumes. offset=0 reads the current counter,
offset>0 atomically increments and returns the new value.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Ubuntu <ubuntu@ip-172-31-55-110.us-west-2.compute.internal>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant