From 6a21f73898d20c1911ae19ea947b8f736b77b07b Mon Sep 17 00:00:00 2001 From: beorn7 Date: Thu, 19 Mar 2015 17:54:59 +0100 Subject: [PATCH] Fixes after review. --- storage/local/persistence.go | 6 +++--- storage/local/storage.go | 15 ++++++++++----- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/storage/local/persistence.go b/storage/local/persistence.go index 7e4fb28242..e4b0e29c3c 100644 --- a/storage/local/persistence.go +++ b/storage/local/persistence.go @@ -482,7 +482,7 @@ func (p *persistence) loadChunkDescs(fp clientmodel.Fingerprint, beforeTime clie // // (4.4) The varint-encoded persistWatermark. (Missing in v1.) // -// (4.5) The modification time of the series file as nanoceconds elapsed since +// (4.5) The modification time of the series file as nanoseconds elapsed since // January 1, 1970 UTC. -1 if the modification time is unknown or no series file // exists yet. (Missing in v1.) // @@ -1235,12 +1235,12 @@ func (p *persistence) openChunkFileForWriting(fp clientmodel.Fingerprint) (*os.F // would still be detected. } -// closeChunkFile first sync's the provided file if mandated so by the sync +// closeChunkFile first syncs the provided file if mandated so by the sync // strategy. Then it closes the file. Errors are logged. func (p *persistence) closeChunkFile(f *os.File) { if p.shouldSync() { if err := f.Sync(); err != nil { - glog.Error("Error sync'ing file:", err) + glog.Error("Error syncing file:", err) } } if err := f.Close(); err != nil { diff --git a/storage/local/storage.go b/storage/local/storage.go index efe69cae74..1d85c75ef2 100644 --- a/storage/local/storage.go +++ b/storage/local/storage.go @@ -73,8 +73,8 @@ const ( Adaptive ) -// A syncStrategy is a function that returns if series files should be sync'd or -// not. It does not need to be goroutine safe. +// A syncStrategy is a function that returns whether series files should be +// synced or not. It does not need to be goroutine safe. type syncStrategy func() bool type memorySeriesStorage struct { @@ -935,16 +935,21 @@ func (s *memorySeriesStorage) incNumChunksToPersist(by int) { // isDegraded returns whether the storage is in "graceful degradation mode", // which is the case if the number of chunks waiting for persistence has reached -// a percentage of maxChunksToPersist that exceepds +// a percentage of maxChunksToPersist that exceeds // percentChunksToPersistForDegradation. The method is not goroutine safe (but // only ever called from the goroutine dealing with series maintenance). // Changes of degradation mode are logged. func (s *memorySeriesStorage) isDegraded() bool { nowDegraded := s.getNumChunksToPersist() > s.maxChunksToPersist*percentChunksToPersistForDegradation/100 if s.degraded && !nowDegraded { - glog.Warning("Storage has left graceful degradation mode.") + glog.Warning("Storage has left graceful degradation mode. Things are back to normal.") } else if !s.degraded && nowDegraded { - glog.Warning("%d chunks waiting for persistence (allowed maximum %d). Storage is now in graceful degradation mode. Series files are not sync'd anymore. Checkpoints will not be performed more often then every %v.", s.getNumChunksToPersist, s.maxChunksToPersist, s.checkpointInterval) + glog.Warningf( + "%d chunks waiting for persistence (%d%% of the allowed maximum %d). Storage is now in graceful degradation mode. Series files are not synced anymore if following the adaptive strategy. Checkpoints are not performed more often than every %v.", + s.getNumChunksToPersist(), + s.getNumChunksToPersist()*100/s.maxChunksToPersist, + s.maxChunksToPersist, + s.checkpointInterval) } s.degraded = nowDegraded return s.degraded