Skip to content
This repository has been archived by the owner on Aug 23, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1062 from grafana/fixIdxPruning
Browse files Browse the repository at this point in the history
acquire/release lock for each series when pruning
  • Loading branch information
Dieterbe authored Sep 24, 2018
2 parents 4b0b8c1 + 65e7229 commit 8bbc022
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions idx/memory/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -1318,20 +1318,23 @@ DEFS:
pruned = append(pruned, defs...)
}

ORGS:
for org, paths := range toPruneUntagged {
if len(paths) == 0 {
continue
}

m.Lock()
tree, ok := m.tree[org]
if !ok {
m.Unlock()
continue
}

for path := range paths {
m.Lock()
tree, ok := m.tree[org]

if !ok {
m.Unlock()
continue ORGS
}

n, ok := tree.Items[path]

if !ok {
m.Unlock()
log.Debug("memory-idx: series %s for orgId:%d was identified for pruning but cannot be found.", path, org)
Expand All @@ -1340,9 +1343,10 @@ DEFS:

log.Debug("memory-idx: series %s for orgId:%d is stale. pruning it.", n.Path, org)
defs := m.delete(org, n, true, false)
m.Unlock()
pruned = append(pruned, defs...)
}
m.Unlock()

}

statMetricsActive.Add(-1 * len(pruned))
Expand Down

0 comments on commit 8bbc022

Please sign in to comment.