allegro / allegro/bigcache

Set failure even when there is enough memory left and size of entry is acceptable

Offen
#214 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
bug
Vorherrschende Sprache
Go
Sterne
8.2k
Forks
614
Ø Merge
5 T. 12 Std.
Gemergte PRs (30 T.)
1

Beschreibung

**What is the issue you are having?**
Set failing with `entry is bigger than max shard size`(2MB) even when there is enough memory left and size of entry is acceptable (38 kb)

**What is BigCache doing that it shouldn't?**
[Error in question](https://github.com/allegro/bigcache/blob/master/shard.go#L147)

Reason [removeOldestEntry](https://github.com/allegro/bigcache/blob/master/shard.go#L145) returned an error

Which was in-turn returned by [Pop](https://github.com/allegro/bigcache/blob/master/shard.go#L292)

[Pop](https://github.com/allegro/bigcache/blob/master/queue/bytes_queue.go#L159) will only return an error if `peek` fails

[Peek](https://github.com/allegro/bigcache/blob/master/queue/bytes_queue.go#L229) `can` return an error if the [queue is empty](https://github.com/allegro/bigcache/blob/master/queue/bytes_queue.go#L215)

`entry is bigger than max shard size` is not the correct error

**Minimal, Complete, and Verifiable Example**
Not able to reproduce it
```
config := &bigcache.Config{
LifeWindow: 2 * time.Hour,
CleanWindow: 1 * time.Second,
HardMaxCacheSize: 1024 * 2,
Shards: 1024,
}
```
But was reading the code and thought this could be one of the reason

When asking a question about a problem caused by your code, you will get much better answers if you provide code we can use to reproduce the problem. That code should be...

* ...Minimal – Use as little code as possible that still produces the same problem
* ...Complete – Provide all parts needed to reproduce the problem
* ...Verifiable – Test the code you're about to provide to make sure it reproduces the problem

For more information on how to provide an MCVE, please see the [Stack Overflow documentation](https://stackoverflow.com/help/mcve).

**Environment:**
- Version (git sha or release):
- OS (e.g. from `/etc/os-release` or winver.exe):
- go version:

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.