Fix deadlock with empty MemPostings

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
This commit is contained in:
Oleg Zaytsev 2024-09-25 14:08:50 +02:00
parent e196b977af
commit 9c417aa710
No known key found for this signature in database
GPG key ID: 7E9FE9FD48F512EF

View file

@ -295,7 +295,8 @@ func (p *MemPostings) Delete(deleted map[storage.SeriesRef]struct{}, affected ma
defer p.mtx.Unlock()
// Deleting label names mutates p.m map, so it should be done from a single goroutine after nobody else is reading it.
deleteLabelNames := make(chan string, len(p.m))
// Adding +1 to length to account for allPostingsKey processing when MemPostings is empty.
deleteLabelNames := make(chan string, len(p.m)+1)
process := func(l labels.Label) {
orig := p.m[l.Name][l.Value]