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

Fix updating of NumTombstones in block.Delete(..) #385

Merged

Conversation

codesome
Copy link
Contributor

Fixes #384

Signed-off-by: Ganesh Vernekar [email protected]

@krasi-georgiev
Copy link
Contributor

krasi-georgiev commented Sep 18, 2018

I would say something like this would be a bit more clear and better to avoid races:


// TombstoneReader gives access to tombstone intervals by series reference.
type TombstoneReader interface {
	...
        // Total returns the total count of Tombstones.
	Total() uint64
}


func (t *memTombstones) Total() uint64 {
	t.mtx.RLock()
	defer t.mtx.RUnlock()

	var total uint64
	for _, intvs := range t.intvlGroups {
		total += uint64(len(intvs))
	}
	return total
}


func (pb *Block) Delete
     ....
     pb.meta.Stats.NumTombstones = pb.tombstones.Total()

@codesome
Copy link
Contributor Author

There wont be any race condition in the current change, but what you proposed looks good. I will add that function.

@codesome codesome force-pushed the invalid-tombstone-count branch from b634671 to 7cd2ee3 Compare September 19, 2018 04:44
@krasi-georgiev
Copy link
Contributor

LGTM

ping @gouthamve

@codesome
Copy link
Contributor Author

ping @gouthamve @krasi-georgiev

@krasi-georgiev krasi-georgiev merged commit 6e71296 into prometheus-junkyard:master Sep 27, 2018
@krasi-georgiev
Copy link
Contributor

Thanks!

@codesome codesome deleted the invalid-tombstone-count branch July 5, 2019 08:04
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants