diff --git a/go.mod b/go.mod index 60524c64265..cd029518095 100644 --- a/go.mod +++ b/go.mod @@ -62,7 +62,7 @@ require ( replace ( github.com/golang/lint => golang.org/x/lint v0.0.0-20190409202823-959b441ac422 github.com/v3io/frames => github.com/v3io/frames v0.8.1 - github.com/v3io/v3io-tsdb => github.com/v3io/v3io-tsdb v0.11.3 + github.com/v3io/v3io-tsdb => github.com/v3io/v3io-tsdb v0.11.4 google.golang.org/grpc => google.golang.org/grpc v1.19.1 k8s.io/klog => github.com/simonpasquier/klog-gokit v0.1.0 ) diff --git a/go.sum b/go.sum index 4adf55b3bbb..540a7428ea6 100644 --- a/go.sum +++ b/go.sum @@ -394,6 +394,8 @@ github.com/v3io/v3io-go v0.1.9 h1:etkrrRmrI++i8sxGfK/+13f41TxIMohYeZHwVUM62vw= github.com/v3io/v3io-go v0.1.9/go.mod h1:5poBlcjZG5TiexRTYI44PE6tHzZz5Z60w+iS899pWtc= github.com/v3io/v3io-tsdb v0.11.3 h1:zH2rVNsPy9CIm0/gwJ7NNyjDD7G2w4XhUygeZqexLaE= github.com/v3io/v3io-tsdb v0.11.3/go.mod h1:kp586KxTfROIGwb/nzNxwDbX2Wterxro+HbiZHmK548= +github.com/v3io/v3io-tsdb v0.11.4 h1:tDw+EdFNregIy6r4fPqtOybkAj4ngUl4WRQNH24Xe0M= +github.com/v3io/v3io-tsdb v0.11.4/go.mod h1:kp586KxTfROIGwb/nzNxwDbX2Wterxro+HbiZHmK548= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasthttp v1.2.0 h1:dzZJf2IuMiclVjdw0kkT+f9u4YdrapbNyGAN47E/qnk= diff --git a/vendor/github.com/v3io/v3io-tsdb/pkg/appender/appender.go b/vendor/github.com/v3io/v3io-tsdb/pkg/appender/appender.go index e1a7cd632d3..c07d819bf25 100644 --- a/vendor/github.com/v3io/v3io-tsdb/pkg/appender/appender.go +++ b/vendor/github.com/v3io/v3io-tsdb/pkg/appender/appender.go @@ -56,7 +56,7 @@ type MetricState struct { store *chunkStore err error retryCount uint8 - newName bool + created bool isVariant bool shouldGetState bool @@ -147,7 +147,6 @@ func NewMetricsCache(container v3io.Container, logger logger.Logger, cfg *config newCache.newUpdates = make(chan int, 1000) newCache.stopChan = make(chan int, 3) - newCache.NameLabelMap = map[string]bool{} newCache.performanceReporter = performance.ReporterInstanceFromConfig(cfg) return &newCache @@ -182,10 +181,6 @@ func (mc *MetricsCache) getMetric(hash uint64) (*MetricState, bool) { // create a new metric and save in the map func (mc *MetricsCache) addMetric(hash uint64, name string, metric *MetricState) { mc.cacheMetricMap.Add(hash, metric) - if _, ok := mc.NameLabelMap[name]; !ok { - metric.newName = true - mc.NameLabelMap[name] = true - } } // Push append to async channel diff --git a/vendor/github.com/v3io/v3io-tsdb/pkg/appender/ingest.go b/vendor/github.com/v3io/v3io-tsdb/pkg/appender/ingest.go index 09b97a9c05b..897f6345f6f 100644 --- a/vendor/github.com/v3io/v3io-tsdb/pkg/appender/ingest.go +++ b/vendor/github.com/v3io/v3io-tsdb/pkg/appender/ingest.go @@ -241,6 +241,9 @@ func (mc *MetricsCache) postMetricUpdates(metric *MetricState) { if !sent { if metric.store.samplesQueueLength() == 0 { metric.setState(storeStateReady) + if metric.store.numNotProcessed == 0 { + mc.cacheMetricMap.ResetMetric(metric.hash) + } } else { if mc.metricQueue.length() > 0 { atomic.AddInt64(&mc.outstandingUpdates, 1) diff --git a/vendor/github.com/v3io/v3io-tsdb/pkg/appender/lru_cache.go b/vendor/github.com/v3io/v3io-tsdb/pkg/appender/lru_cache.go index 1efa312bb3e..f8d13b3168a 100644 --- a/vendor/github.com/v3io/v3io-tsdb/pkg/appender/lru_cache.go +++ b/vendor/github.com/v3io/v3io-tsdb/pkg/appender/lru_cache.go @@ -35,21 +35,18 @@ func NewCache(max int) *Cache { func (c *Cache) Add(key uint64, value *MetricState) { c.mtx.Lock() defer c.mtx.Unlock() - if ee, ok := c.cache[key]; ok { - c.free.Remove(ee) - //check if element was already in list and if not push to front - c.used.MoveToFront(ee) - if c.used.Front() != ee { - c.used.PushFront(ee) - } - ee.Value.(*entry).value = value - return + if ele, ok := c.cache[key]; ok { + //deleting from both lists as a workaround to not knowing which list actually contains the elem + //if the elem is not present in the list Remove won't do anything + // Remove clears ele's head,prev and next pointers so it can't be reused + c.free.Remove(ele) + c.used.Remove(ele) } - ele := c.used.PushFront(&entry{key, value}) - c.cache[key] = ele + c.cache[key] = c.used.PushFront(&entry{key, value}) if c.maxEntries != 0 && c.free.Len()+c.used.Len() > c.maxEntries { c.removeOldest() } + } // Get looks up a key's value from the cache. @@ -57,12 +54,12 @@ func (c *Cache) Get(key uint64) (value *MetricState, ok bool) { c.mtx.Lock() defer c.mtx.Unlock() if ele, hit := c.cache[key]; hit { + //deleting from both lists as a workaround to not knowing which list actually contains the elem + //if the elem is not present in the list Remove won't do anything + // Remove clears ele's head,prev and next pointers so it can't be reused c.free.Remove(ele) - //check if element was already in list and if not push to front - c.used.MoveToFront(ele) - if c.used.Front() != ele { - c.used.PushFront(ele) - } + c.used.Remove(ele) + c.cache[key] = c.used.PushFront(&entry{key, ele.Value.(*entry).value}) return ele.Value.(*entry).value, true } return @@ -73,8 +70,7 @@ func (c *Cache) removeOldest() { ele := c.free.Back() if ele != nil { c.free.Remove(ele) - kv := ele.Value.(*clist.Element).Value.(*entry) - delete(c.cache, kv.key) + delete(c.cache, ele.Value.(*entry).key) return } c.cond.Wait() @@ -85,8 +81,12 @@ func (c *Cache) ResetMetric(key uint64) { c.mtx.Lock() defer c.mtx.Unlock() if ele, ok := c.cache[key]; ok { + //deleting from both lists as a workaround to not knowing which list actually contains the elem + //if the elem is not present in the list Remove won't do anything + // Remove clears ele's head,prev and next pointers so it can't be reused c.used.Remove(ele) - c.free.PushFront(ele) + c.free.Remove(ele) + c.cache[key] = c.free.PushFront(&entry{key, ele.Value.(*entry).value}) c.cond.Signal() } } diff --git a/vendor/github.com/v3io/v3io-tsdb/pkg/appender/store.go b/vendor/github.com/v3io/v3io-tsdb/pkg/appender/store.go index c2b7bdf83a4..4a0130f8d98 100644 --- a/vendor/github.com/v3io/v3io-tsdb/pkg/appender/store.go +++ b/vendor/github.com/v3io/v3io-tsdb/pkg/appender/store.go @@ -186,7 +186,8 @@ func (cs *chunkStore) processGetResp(mc *MetricsCache, metric *MetricState, resp if resp.Error != nil { if utils.IsNotExistsError(resp.Error) { - if metric.newName { + if !metric.created { + metric.created = true path := filepath.Join(mc.cfg.TablePath, config.NamesDirectory, metric.name) putInput := v3io.PutItemInput{Path: path, Attributes: map[string]interface{}{}} diff --git a/vendor/modules.txt b/vendor/modules.txt index 3202edab8cb..e0162a88773 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -341,7 +341,7 @@ github.com/v3io/v3io-go/pkg/dataplane github.com/v3io/v3io-go/pkg/dataplane/http github.com/v3io/v3io-go/pkg/dataplane/schemas/node/common github.com/v3io/v3io-go/pkg/errors -# github.com/v3io/v3io-tsdb v0.11.2 => github.com/v3io/v3io-tsdb v0.11.3 +# github.com/v3io/v3io-tsdb v0.11.2 => github.com/v3io/v3io-tsdb v0.11.4 github.com/v3io/v3io-tsdb/internal/pkg/performance github.com/v3io/v3io-tsdb/pkg/aggregate github.com/v3io/v3io-tsdb/pkg/appender diff --git a/web/web.go b/web/web.go index 79c0454a2e1..74272d857a0 100644 --- a/web/web.go +++ b/web/web.go @@ -73,6 +73,7 @@ import ( v3ioConfig "github.com/v3io/v3io-tsdb/pkg/config" ) + var ( localhostRepresentations = []string{"127.0.0.1", "localhost"} @@ -828,13 +829,15 @@ func (h *Handler) status(w http.ResponseWriter, r *http.Request) { status.LastConfigTime = time.Unix(int64(toFloat64(mF)), 0) } } - db := h.tsdb() - startTime := time.Now().UnixNano() - status.Stats = db.Head().PostingsCardinalityStats("__name__") - status.Duration = fmt.Sprintf("%.3f", float64(time.Now().UnixNano()-startTime)/float64(1e9)) - status.NumSeries = db.Head().NumSeries() - status.MaxTime = db.Head().MaxTime() - status.MinTime = db.Head().MaxTime() + // TODO: Implement for V3IO (IG-16879) + //db := h.tsdb() + //startTime := time.Now().UnixNano() + status.Stats = &index.PostingsStats{} + //status.Stats = db.Head().PostingsCardinalityStats("__name__") + //status.Duration = fmt.Sprintf("%.3f", float64(time.Now().UnixNano()-startTime)/float64(1e9)) + //status.NumSeries = db.Head().NumSeries() + //status.MaxTime = db.Head().MaxTime() + //status.MinTime = db.Head().MaxTime() h.executeTemplate(w, "status.html", status) }