I'm not very comfortable with using an equality check on errors, but I'm
copying the same code from Prometheus:
f711d71aa8/tsdb/querier.go (L532-L533)
Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
When a particular SeriesLifecycleCallback tries to optimize and run
closer to the Head, keeping track of the HeadSeriesRef instead of the
labelsets, it's impossible to handle the PostDeletion callback properly
as there's no way to know which series refs were deleted from the head.
This changes the callback to provide the series refs alongside the
labelsets, so the implementation can choose what to do.
Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
When compiled with `-tags stringlabels`, the names and values point into
a larger block of memory containing all labels. Garbage-collection
considers the entire block "live" if you point to a part of it, so the
map ends up retaining all labels for (nearly) all series.
Cloning the string value avoids this problem, and we check first if the
value is already in the map. Since the clone is more expensive, only do
it when built with `-tags stringlabels`.
Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
If a new series is introduced in a storage.Appender instance, that
series should be written to the WAL once the storage.Appender is closed,
even on Rollback.
Previously, new series would only be written to the WAL when calling
Commit. However, because the series is stored in memory regardless,
subsequent calls to Commit may write samples to the WAL which reference
a series ID which that was never written.
Related to #11589. It's likely that this fix also resolves this issue,
but we need more testing from users to see if the problem persists after
this fix; there may be more cases where samples get written to the WAL
in Prometheus Agent mode without the corresponding series record.
Signed-off-by: Robert Fratto <robertfratto@gmail.com>
* Optimize labelValues when matchers select small number of series.
Signed-off-by: Peter Štibraný <pstibrany@gmail.com>
* Address review feedback.
Signed-off-by: Peter Štibraný <pstibrany@gmail.com>
* Add missing p.Err()
Signed-off-by: Peter Štibraný <pstibrany@gmail.com>
* Reuse existing slice with all label values.
Signed-off-by: Peter Štibraný <pstibrany@gmail.com>
* Simplify check for expanded postings.
Signed-off-by: Peter Štibraný <pstibrany@gmail.com>
* Fix comment.
Signed-off-by: Peter Štibraný <pstibrany@gmail.com>
---------
Signed-off-by: Peter Štibraný <pstibrany@gmail.com>
This has become a requirement for native histograms, as a single
histogram sample commonly has many buckets, so that providing many
exemplars makes sense.
Since OM text doesn't support native histograms yet, the test had to
be expanded to also support protobuf test cases.
Signed-off-by: beorn7 <beorn@grafana.com>
Snappy remains as the default compression but there is now a flag to switch
the compression algorithm.
Signed-off-by: Justin Lei <justin.lei@grafana.com>
* Apply matchers when fetching label values
Signed-off-by: Patrick Oyarzun <patrick.oyarzun@grafana.com>
* Avoid extra copying of label values
Signed-off-by: Patrick Oyarzun <patrick.oyarzun@grafana.com>
---------
Signed-off-by: Patrick Oyarzun <patrick.oyarzun@grafana.com>