Skip to content

Commit 2e05e88

Browse files
authored
Public UpdateTxnSafePointCache again to be used in tests in TiDB (#1732)
Signed-off-by: MyonKeminta <[email protected]>
1 parent 1a0daf3 commit 2e05e88

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

tikv/interface.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ type Storage interface {
5858
// GetSafePointKV gets the SafePointKV.
5959
GetSafePointKV() SafePointKV
6060

61+
// UpdateTxnSafePointCache updates the cached txn safe point, which is used for safety check of data access
62+
// operations to prevent accessing GC-ed inconsistent data.
63+
// WARNING: Exported only for test purpose. Avoid using it when possible.
64+
UpdateTxnSafePointCache(txnSafePoint uint64, now time.Time)
65+
6166
// SetOracle sets the Oracle.
6267
SetOracle(oracle oracle.Oracle)
6368

tikv/kv.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,9 @@ func (s *KVStore) Go(f func()) error {
171171
return s.gP.Run(f)
172172
}
173173

174-
// updateTxnSafePointCache updates the cached txn safe point, which is used for safety check of data access
174+
// UpdateTxnSafePointCache updates the cached txn safe point, which is used for safety check of data access
175175
// operations to prevent accessing GC-ed inconsistent data.
176-
func (s *KVStore) updateTxnSafePointCache(txnSafePoint uint64, now time.Time) {
176+
func (s *KVStore) UpdateTxnSafePointCache(txnSafePoint uint64, now time.Time) {
177177
s.gcStateCacheMu.Lock()
178178
defer s.gcStateCacheMu.Unlock()
179179

@@ -354,7 +354,7 @@ func NewKVStore(uuid string, pdClient pd.Client, spkv SafePointKV, tikvclient Cl
354354
if err != nil {
355355
return nil, errors.WithStack(err)
356356
}
357-
store.updateTxnSafePointCache(txnSafePoint, time.Now())
357+
store.UpdateTxnSafePointCache(txnSafePoint, time.Now())
358358
store.clientMu.client = client.NewReqCollapse(client.NewInterceptedClient(tikvclient))
359359
store.clientMu.client.SetEventListener(regionCache.GetClientEventListener())
360360

@@ -418,7 +418,7 @@ func (s *KVStore) runTxnSafePointUpdater() {
418418
case now := <-time.After(d):
419419
txnSafePoint, err := s.loadTxnSafePoint(context.Background())
420420
if err == nil {
421-
s.updateTxnSafePointCache(txnSafePoint, now)
421+
s.UpdateTxnSafePointCache(txnSafePoint, now)
422422
d = pollTxnSafePointInterval
423423
} else {
424424
d = pollTxnSafePointQuickRepeatInterval

tikv/test_probe.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ outerLoop:
159159
}
160160

161161
func (s StoreProbe) UpdateTxnSafePointCache(txnSafePoint uint64, now time.Time) {
162-
s.KVStore.updateTxnSafePointCache(txnSafePoint, now)
162+
s.KVStore.UpdateTxnSafePointCache(txnSafePoint, now)
163163
}
164164

165165
func (s StoreProbe) GetGCStatesClient() pdgc.GCStatesClient {

0 commit comments

Comments
 (0)