mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-27 06:29:42 -08:00
Remove archiveMtx.
Change-Id: Ie8019f860bbda68621f74380c90a4e57930d3d7a
This commit is contained in:
parent
7af42eda65
commit
c087ee35f7
|
@ -86,11 +86,6 @@ type persistence struct {
|
||||||
basePath string
|
basePath string
|
||||||
chunkLen int
|
chunkLen int
|
||||||
|
|
||||||
// archiveMtx protects the archiving-related methods archiveMetric,
|
|
||||||
// unarchiveMetric, dropArchiveMetric, and getFingerprintsModifiedBefore
|
|
||||||
// from concurrent calls.
|
|
||||||
archiveMtx sync.Mutex
|
|
||||||
|
|
||||||
archivedFingerprintToMetrics *index.FingerprintMetricIndex
|
archivedFingerprintToMetrics *index.FingerprintMetricIndex
|
||||||
archivedFingerprintToTimeRange *index.FingerprintTimeRangeIndex
|
archivedFingerprintToTimeRange *index.FingerprintTimeRangeIndex
|
||||||
labelPairToFingerprints *index.LabelPairFingerprintIndex
|
labelPairToFingerprints *index.LabelPairFingerprintIndex
|
||||||
|
@ -1155,13 +1150,10 @@ func (p *persistence) waitForIndexing() {
|
||||||
|
|
||||||
// archiveMetric persists the mapping of the given fingerprint to the given
|
// archiveMetric persists the mapping of the given fingerprint to the given
|
||||||
// metric, together with the first and last timestamp of the series belonging to
|
// metric, together with the first and last timestamp of the series belonging to
|
||||||
// the metric. This method is goroutine-safe.
|
// the metric. The caller must have locked the fingerprint.
|
||||||
func (p *persistence) archiveMetric(
|
func (p *persistence) archiveMetric(
|
||||||
fp clientmodel.Fingerprint, m clientmodel.Metric, first, last clientmodel.Timestamp,
|
fp clientmodel.Fingerprint, m clientmodel.Metric, first, last clientmodel.Timestamp,
|
||||||
) error {
|
) error {
|
||||||
p.archiveMtx.Lock()
|
|
||||||
defer p.archiveMtx.Unlock()
|
|
||||||
|
|
||||||
if err := p.archivedFingerprintToMetrics.Put(codable.Fingerprint(fp), codable.Metric(m)); err != nil {
|
if err := p.archivedFingerprintToMetrics.Put(codable.Fingerprint(fp), codable.Metric(m)); err != nil {
|
||||||
p.setDirty(true)
|
p.setDirty(true)
|
||||||
return err
|
return err
|
||||||
|
@ -1196,12 +1188,6 @@ func (p *persistence) updateArchivedTimeRange(
|
||||||
// that have live samples before the provided timestamp. This method is
|
// that have live samples before the provided timestamp. This method is
|
||||||
// goroutine-safe.
|
// goroutine-safe.
|
||||||
func (p *persistence) getFingerprintsModifiedBefore(beforeTime clientmodel.Timestamp) ([]clientmodel.Fingerprint, error) {
|
func (p *persistence) getFingerprintsModifiedBefore(beforeTime clientmodel.Timestamp) ([]clientmodel.Fingerprint, error) {
|
||||||
// The locking makes sure archivedFingerprintToTimeRange won't be
|
|
||||||
// mutated while being iterated over (which will probably not result in
|
|
||||||
// races, but might still yield weird results).
|
|
||||||
p.archiveMtx.Lock()
|
|
||||||
defer p.archiveMtx.Unlock()
|
|
||||||
|
|
||||||
var fp codable.Fingerprint
|
var fp codable.Fingerprint
|
||||||
var tr codable.TimeRange
|
var tr codable.TimeRange
|
||||||
fps := []clientmodel.Fingerprint{}
|
fps := []clientmodel.Fingerprint{}
|
||||||
|
@ -1229,7 +1215,8 @@ func (p *persistence) getArchivedMetric(fp clientmodel.Fingerprint) (clientmodel
|
||||||
|
|
||||||
// dropArchivedMetric deletes an archived fingerprint and its corresponding
|
// dropArchivedMetric deletes an archived fingerprint and its corresponding
|
||||||
// metric entirely. It also queues the metric for un-indexing (no need to call
|
// metric entirely. It also queues the metric for un-indexing (no need to call
|
||||||
// unindexMetric for the deleted metric.) This method is goroutine-safe.
|
// unindexMetric for the deleted metric.) The caller must have locked the
|
||||||
|
// fingerprint.
|
||||||
func (p *persistence) dropArchivedMetric(fp clientmodel.Fingerprint) (err error) {
|
func (p *persistence) dropArchivedMetric(fp clientmodel.Fingerprint) (err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1237,9 +1224,6 @@ func (p *persistence) dropArchivedMetric(fp clientmodel.Fingerprint) (err error)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
p.archiveMtx.Lock()
|
|
||||||
defer p.archiveMtx.Unlock()
|
|
||||||
|
|
||||||
metric, err := p.getArchivedMetric(fp)
|
metric, err := p.getArchivedMetric(fp)
|
||||||
if err != nil || metric == nil {
|
if err != nil || metric == nil {
|
||||||
return err
|
return err
|
||||||
|
@ -1257,10 +1241,17 @@ func (p *persistence) dropArchivedMetric(fp clientmodel.Fingerprint) (err error)
|
||||||
// unarchiveMetric deletes an archived fingerprint and its metric, but (in
|
// unarchiveMetric deletes an archived fingerprint and its metric, but (in
|
||||||
// contrast to dropArchivedMetric) does not un-index the metric. If a metric
|
// contrast to dropArchivedMetric) does not un-index the metric. If a metric
|
||||||
// was actually deleted, the method returns true and the first time of the
|
// was actually deleted, the method returns true and the first time of the
|
||||||
// deleted metric. This method is goroutine-safe.
|
// deleted metric. The caller must have locked the fingerprint.
|
||||||
func (p *persistence) unarchiveMetric(fp clientmodel.Fingerprint) (bool, clientmodel.Timestamp, error) {
|
func (p *persistence) unarchiveMetric(fp clientmodel.Fingerprint) (
|
||||||
p.archiveMtx.Lock()
|
deletedAnything bool,
|
||||||
defer p.archiveMtx.Unlock()
|
firstDeletedTime clientmodel.Timestamp,
|
||||||
|
err error,
|
||||||
|
) {
|
||||||
|
defer func() {
|
||||||
|
if err != nil {
|
||||||
|
p.setDirty(true)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
firstTime, _, has, err := p.archivedFingerprintToTimeRange.Lookup(fp)
|
firstTime, _, has, err := p.archivedFingerprintToTimeRange.Lookup(fp)
|
||||||
if err != nil || !has {
|
if err != nil || !has {
|
||||||
|
|
|
@ -359,7 +359,6 @@ func (s *memorySeriesStorage) getOrCreateSeries(fp clientmodel.Fingerprint, m cl
|
||||||
unarchived, firstTime, err := s.persistence.unarchiveMetric(fp)
|
unarchived, firstTime, err := s.persistence.unarchiveMetric(fp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Error unarchiving fingerprint %v: %v", fp, err)
|
glog.Errorf("Error unarchiving fingerprint %v: %v", fp, err)
|
||||||
s.persistence.setDirty(true)
|
|
||||||
}
|
}
|
||||||
if unarchived {
|
if unarchived {
|
||||||
s.seriesOps.WithLabelValues(unarchive).Inc()
|
s.seriesOps.WithLabelValues(unarchive).Inc()
|
||||||
|
@ -375,16 +374,6 @@ func (s *memorySeriesStorage) getOrCreateSeries(fp clientmodel.Fingerprint, m cl
|
||||||
return series
|
return series
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
func (s *memorySeriesStorage) preloadChunksAtTime(fp clientmodel.Fingerprint, ts clientmodel.Timestamp) (chunkDescs, error) {
|
|
||||||
series, ok := s.fpToSeries.get(fp)
|
|
||||||
if !ok {
|
|
||||||
panic("requested preload for non-existent series")
|
|
||||||
}
|
|
||||||
return series.preloadChunksAtTime(ts, s.persistence)
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
func (s *memorySeriesStorage) preloadChunksForRange(
|
func (s *memorySeriesStorage) preloadChunksForRange(
|
||||||
fp clientmodel.Fingerprint,
|
fp clientmodel.Fingerprint,
|
||||||
from clientmodel.Timestamp, through clientmodel.Timestamp,
|
from clientmodel.Timestamp, through clientmodel.Timestamp,
|
||||||
|
|
Loading…
Reference in a new issue