Skip to content

Commit 13b05ef

Browse files
committed
revert locking changes in indexer
Signed-off-by: Nir Rozenbaum <[email protected]>
1 parent cff0f01 commit 13b05ef

File tree

1 file changed

+6
-3
lines changed
  • pkg/epp/scheduling/framework/plugins/multi/prefix

1 file changed

+6
-3
lines changed

pkg/epp/scheduling/framework/plugins/multi/prefix/indexer.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,22 +52,23 @@ func newIndexer(ctx context.Context, maxLRUSize int) *indexer {
5252
// Add adds a list of prefix hashes to the cache, tied to the server.
5353
func (i *indexer) Add(hashes []BlockHash, pod ServerID) {
5454
i.mu.Lock()
55-
defer i.mu.Unlock()
56-
5755
// Check if the LRU pod exist
5856
lruForPod, exists := i.podToLRU[pod]
5957
if !exists {
60-
newLRU, _ := lru.NewWithEvict(i.maxLRUSize, i.makeEvictionFn(pod))
58+
newLRU, _ := lru.NewWithEvict[BlockHash, struct{}](i.maxLRUSize, i.makeEvictionFn(pod))
6159
i.podToLRU[pod] = newLRU
6260
lruForPod = newLRU
6361
}
6462

63+
i.mu.Unlock()
64+
6565
// Add to LRU (may evict)
6666
for _, hash := range hashes {
6767
lruForPod.Add(hash, struct{}{})
6868
}
6969

7070
// Update hashToPods once under lock
71+
i.mu.Lock()
7172
for _, hash := range hashes {
7273
pods := i.hashToPods[hash]
7374
if pods == nil {
@@ -76,6 +77,8 @@ func (i *indexer) Add(hashes []BlockHash, pod ServerID) {
7677
pods[pod] = struct{}{}
7778
i.hashToPods[hash] = pods
7879
}
80+
81+
i.mu.Unlock()
7982
}
8083

8184
// Get returns a set of servers that have the given prefix hash cached.

0 commit comments

Comments
 (0)