Skip to content

Commit

Permalink
fix: check ownedPartitionCount before setting LRU stats
Browse files Browse the repository at this point in the history
  • Loading branch information
buraksezer committed Jan 15, 2023
1 parent cd7dfe8 commit 700ee31
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions internal/dmap/put.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,17 @@ func (dm *DMap) setLRUEvictionStats(e *env) error {
// But I think that it's good to use only one of time in a production system.
// Because it should be easy to understand and debug.
st := e.fragment.storage.Stats()

// This works for every request if you enabled LRU.
// But loading a number from memory should be very cheap.
// ownedPartitionCount changes in the case of node join or leave.
ownedPartitionCount := dm.s.rt.OwnedPartitionCount()
if ownedPartitionCount == 0 {
// Routing table is an eventually consistent data structure. In order to prevent a panic in prod,
// check the owned partition count before doing math.
return nil
}

if dm.config.maxKeys > 0 {
// MaxKeys controls maximum key count owned by this node.
// We need ownedPartitionCount property because every partition
Expand Down

0 comments on commit 700ee31

Please sign in to comment.