allegro / allegro/bigcache

set value happen to panic

Abierto
#297 0 comentarios 0 reacciones 0 asignados Ver en GitHub
bug
Lenguaje dominante
Go
Estrellas
8.2k
Forks
614
Merge medio
5 d 12 h
PR fusionados (30 d)
1

Descripción

**What is the issue you are having?**

021-11-04 14:01:50.079 ERROR logs/recovery.go:75 [RECOVERY] 2021/11/04 - 14:01:50 panic recovered:
runtime error: index out of range [7] with length 5
/usr/local/go/src/runtime/panic.go:969 (0x436495)
gopanic: ???
/usr/local/go/src/runtime/panic.go:88 (0x4342b2)
goPanicIndex:
/usr/local/go/src/encoding/binary/binary.go:77 (0xbba46f)
littleEndian.Uint64: return uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 |
/usr/local/app/go/pkg/mod/github.com/allegro/bigcache/v3@v3.0.0/encoding.go:78 (0xbba358)
readHashFromEntry: uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56
/usr/local/app/go/pkg/mod/github.com/allegro/bigcache/v3@v3.0.0/shard.go:318 (0xbba357)
(*cacheShard).removeOldestEntry: order.PutUint32(bs, *v)
/usr/local/app/go/pkg/mod/github.com/allegro/bigcache/v3@v3.0.0/shard.go:271 (0xbb9e84)
(*cacheShard).onEvict: case []bool:
/usr/local/app/go/pkg/mod/github.com/allegro/bigcache/v3@v3.0.0/shard.go:132 (0xbb90be)
(*cacheShard).set: b[1] = byte(v >> 48)
/usr/local/app/go/pkg/mod/github.com/allegro/bigcache/v3@v3.0.0/bigcache.go:133 (0xbb57cb)
(*BigCache).Set: b[2] = byte(v >> 40)

**What is BigCache doing that it shouldn't?**

I find when set value, bigcache will remove the oldest entry, but panic.

**Minimal, Complete, and Verifiable Example**

init paramters:
cache := bigcache.New(

bigcache.WithShards(256),

bigcache.WithLifeWindow(60*time.Second),

bigcache.WithCleanWindow(60*time.Second),

bigcache.WithMaxEntriesInWindow(10000),

bigcache.WithMaxEntrySize(30),
)

stoage struct:
type liveStatusCache struct {
Uin uint64
Status int
StartTime int64
Source int
Account string
RoomID string
Rowkey string
AndroidMobileQQURL string
IOSMobileQQURL string
AndroidKDAppURL string
IOSKDAppURL string
}

serialization type:
json

set value code:
func (a *liveCache) set(liveStatus *liveStatusCache) error {
if err := a.cache.Set(strconv.FormatUint(liveStatus.Uin, 10),
liveStatus, codec.SerializationTypeJSON); err != nil {
return err
}
return nil
}

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

**Environment:**
- OS (e.g. from `/etc/os-release` or winver.exe): Linux 9-218-33-66 5.4.119-1-tlinux4-0007
- go version: 1.16

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.