Skip to content

Commit

Permalink
Fix the panic
Browse files Browse the repository at this point in the history
Signed-off-by: JmPotato <ghzpotato@gmail.com>
  • Loading branch information
JmPotato committed Mar 13, 2023
1 parent eece096 commit 55e0b31
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tikv/kv.go
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ func (s *KVStore) updateSafeTS(ctx context.Context) {

// CreateRURuntimeStats creates a RURuntimeStats for the startTS and returns it.
func (s *KVStore) CreateRURuntimeStats(startTS uint64) *util.RURuntimeStats {
rrs, _ := s.ruRuntimeStatsMap.LoadOrStore(startTS, &util.RURuntimeStats{})
rrs, _ := s.ruRuntimeStatsMap.LoadOrStore(startTS, util.NewRURuntimeStats())
return rrs.(*util.RURuntimeStats)
}

Expand Down
8 changes: 8 additions & 0 deletions util/execdetails.go
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,14 @@ type RURuntimeStats struct {
writeRU *uatomic.Float64
}

// NewRURuntimeStats creates a new RURuntimeStats.
func NewRURuntimeStats() *RURuntimeStats {
return &RURuntimeStats{
readRU: uatomic.NewFloat64(0),
writeRU: uatomic.NewFloat64(0),
}
}

// Clone implements the RuntimeStats interface.
func (rs *RURuntimeStats) Clone() *RURuntimeStats {
return &RURuntimeStats{
Expand Down

0 comments on commit 55e0b31

Please sign in to comment.