diff --git a/go.mod b/go.mod index abc5db627..9fefc60b4 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/VictoriaMetrics/VictoriaMetrics require ( cloud.google.com/go v0.50.0 // indirect cloud.google.com/go/storage v1.4.0 - github.com/VictoriaMetrics/fastcache v1.5.4 + github.com/VictoriaMetrics/fastcache v1.5.5 github.com/VictoriaMetrics/metrics v1.9.3 github.com/aws/aws-sdk-go v1.26.8 github.com/cespare/xxhash/v2 v2.1.1 diff --git a/go.sum b/go.sum index 4d921bfae..9a5c2a9d0 100644 --- a/go.sum +++ b/go.sum @@ -20,8 +20,8 @@ dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7 github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/VictoriaMetrics/fastcache v1.5.4 h1:0BaXbRH01RycJk79OOBwMCXlNryko9z4yEf6RqbP+Xo= -github.com/VictoriaMetrics/fastcache v1.5.4/go.mod h1:ptDBkNMQI4RtmVo8VS/XwRY6RoTu1dAWCbrk+6WsEM8= +github.com/VictoriaMetrics/fastcache v1.5.5 h1:HsBlzPgzKG0566YOl1mmfyz8SCU0zLKfbl9RDLsiLD8= +github.com/VictoriaMetrics/fastcache v1.5.5/go.mod h1:ptDBkNMQI4RtmVo8VS/XwRY6RoTu1dAWCbrk+6WsEM8= github.com/VictoriaMetrics/metrics v1.9.3 h1:+1kZnOIb8RY825Nb9q9yMrPcOYuPE2GrZWxUh59XnHI= github.com/VictoriaMetrics/metrics v1.9.3/go.mod h1:LU2j9qq7xqZYXz8tF3/RQnB2z2MbZms5TDiIg9/NHiQ= github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8= diff --git a/vendor/github.com/VictoriaMetrics/fastcache/fastcache.go b/vendor/github.com/VictoriaMetrics/fastcache/fastcache.go index b83fd2a85..20a3c0218 100644 --- a/vendor/github.com/VictoriaMetrics/fastcache/fastcache.go +++ b/vendor/github.com/VictoriaMetrics/fastcache/fastcache.go @@ -168,7 +168,7 @@ func (c *Cache) Get(dst, k []byte) []byte { func (c *Cache) HasGet(dst, k []byte) ([]byte, bool) { h := xxhash.Sum64(k) idx := h % bucketsCount - return c.buckets[idx].Get(nil, k, h, true) + return c.buckets[idx].Get(dst, k, h, true) } // Has returns true if entry for the given key k exists in the cache. diff --git a/vendor/github.com/VictoriaMetrics/fastcache/file.go b/vendor/github.com/VictoriaMetrics/fastcache/file.go index de1bb07c5..027c418f8 100644 --- a/vendor/github.com/VictoriaMetrics/fastcache/file.go +++ b/vendor/github.com/VictoriaMetrics/fastcache/file.go @@ -205,6 +205,9 @@ func loadMetadata(dir string) (uint64, error) { if err != nil { return 0, fmt.Errorf("cannot read maxBucketChunks from %q: %s", metadataPath, err) } + if maxBucketChunks == 0 { + return 0, fmt.Errorf("invalid maxBucketChunks=0 read from %q", metadataPath) + } return maxBucketChunks, nil } @@ -359,10 +362,16 @@ func (b *bucket) Load(r io.Reader, maxChunks uint64) error { } for chunkIdx := uint64(0); chunkIdx < chunksLen; chunkIdx++ { chunk := getChunk() + chunks[chunkIdx] = chunk if _, err := io.ReadFull(r, chunk); err != nil { + // Free up allocated chunks before returning the error. + for _, chunk := range chunks { + if chunk != nil { + putChunk(chunk) + } + } return fmt.Errorf("cannot read b.chunks[%d]: %s", chunkIdx, err) } - chunks[chunkIdx] = chunk } // Adjust len for the chunk pointed by currChunkIdx. if chunksLen > 0 { diff --git a/vendor/modules.txt b/vendor/modules.txt index 447512b6b..d0d093c8e 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -10,7 +10,7 @@ cloud.google.com/go/internal/version cloud.google.com/go/storage # github.com/BurntSushi/toml v0.3.1 github.com/BurntSushi/toml -# github.com/VictoriaMetrics/fastcache v1.5.4 +# github.com/VictoriaMetrics/fastcache v1.5.5 github.com/VictoriaMetrics/fastcache # github.com/VictoriaMetrics/metrics v1.9.3 github.com/VictoriaMetrics/metrics