allegro / allegro/bigcache

set value happen to panic

オープン
#297 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
bug
主要言語
Go
スター
8.2k
フォーク
614
平均マージ
5日 12時間
マージ済み PR(30日)
1

説明

**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

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。