Problem
When running BR (Backup & Restore) with keyspace enabled, the current GC safepoint management uses the deprecated global UpdateServiceGCSafePoint API which doesn't support keyspace isolation. This causes BR operations to fail or behave incorrectly in multi-tenant keyspace scenarios.
Root Cause
The existing BR code directly calls pd.Client.UpdateServiceGCSafePoint() which operates at the global cluster level, not per-keyspace. In keyspace mode, BR should use the new SetGCBarrier / DeleteGCBarrier APIs to set per-keyspace GC barriers.
Solution
Implement a GC manager abstraction layer that:
- Automatically detects whether keyspace mode is enabled (via
--keyspace-name parameter)
- For non-keyspace mode: uses the existing global
UpdateServiceGCSafePoint API (backward compatible)
- For keyspace mode: uses the new
SetGCBarrier / DeleteGCBarrier APIs
Changes
- Add
gc_manager.go: Factory and wrapper functions
- Add
gc_manager_unified.go: Implementation for non-keyspace mode
- Add
gc_manager_keyspace.go: Implementation for keyspace mode
- Add
gc_manager_test.go: Unit tests with >85% coverage
- Update
backup.go, restore.go, stream.go, etc. to use new *WithStorage wrapper functions
Testing
- Unit tests covering both keyspace and non-keyspace scenarios
- Tests verify correct API selection based on keyspace configuration
- Backward compatibility verified for existing non-keyspace deployments
Related
- PD API:
GCStatesClient.SetGCBarrier() / DeleteGCBarrier()
Problem
When running BR (Backup & Restore) with keyspace enabled, the current GC safepoint management uses the deprecated global
UpdateServiceGCSafePointAPI which doesn't support keyspace isolation. This causes BR operations to fail or behave incorrectly in multi-tenant keyspace scenarios.Root Cause
The existing BR code directly calls
pd.Client.UpdateServiceGCSafePoint()which operates at the global cluster level, not per-keyspace. In keyspace mode, BR should use the newSetGCBarrier/DeleteGCBarrierAPIs to set per-keyspace GC barriers.Solution
Implement a GC manager abstraction layer that:
--keyspace-nameparameter)UpdateServiceGCSafePointAPI (backward compatible)SetGCBarrier/DeleteGCBarrierAPIsChanges
gc_manager.go: Factory and wrapper functionsgc_manager_unified.go: Implementation for non-keyspace modegc_manager_keyspace.go: Implementation for keyspace modegc_manager_test.go: Unit tests with >85% coveragebackup.go,restore.go,stream.go, etc. to use new*WithStoragewrapper functionsTesting
Related
GCStatesClient.SetGCBarrier()/DeleteGCBarrier()