From 112a778922f1570e8928f8e977f8bab90d59b347 Mon Sep 17 00:00:00 2001 From: Fabian Reinartz Date: Thu, 21 May 2015 01:37:04 +0200 Subject: [PATCH] Align int64s for atomic operations --- storage/local/mapper.go | 8 +++++--- storage/local/storage.go | 9 +++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/storage/local/mapper.go b/storage/local/mapper.go index f3d9c94818..5fcb5cbfe0 100644 --- a/storage/local/mapper.go +++ b/storage/local/mapper.go @@ -23,12 +23,14 @@ type fpMappings map[clientmodel.Fingerprint]map[string]clientmodel.Fingerprint // fpMapper is used to map fingerprints in order to work around fingerprint // collisions. type fpMapper struct { + // highestMappedFP has to be aligned for atomic operations. + highestMappedFP clientmodel.Fingerprint + mtx sync.RWMutex // Protects mappings. mappings fpMappings - fpToSeries *seriesMap - p *persistence - highestMappedFP clientmodel.Fingerprint + fpToSeries *seriesMap + p *persistence } // newFPMapper loads the collision map from the persistence and diff --git a/storage/local/storage.go b/storage/local/storage.go index f9dc91ef5b..a57f2e84e5 100644 --- a/storage/local/storage.go +++ b/storage/local/storage.go @@ -79,6 +79,11 @@ const ( type syncStrategy func() bool type memorySeriesStorage struct { + // numChunksToPersist has to be aligned for atomic operations. + numChunksToPersist int64 // The number of chunks waiting for persistence. + maxChunksToPersist int // If numChunksToPersist reaches this threshold, ingestion will stall. + degraded bool + fpLocker *fingerprintLocker fpToSeries *seriesMap @@ -90,10 +95,6 @@ type memorySeriesStorage struct { checkpointInterval time.Duration checkpointDirtySeriesLimit int - numChunksToPersist int64 // The number of chunks waiting for persistence. - maxChunksToPersist int // If numChunksToPersist reaches this threshold, ingestion will stall. - degraded bool - persistence *persistence mapper *fpMapper