patrickmn / go-cache

An in-memory key:value store/cache (similar to Memcached) library for Go, suitable for single-machine applications.
https://patrickmn.com/projects/go-cache/
MIT License
8.16k stars 874 forks source link

sync.runtime_SemacquireMutex(0xc02c98fbf0?, 0x1f?, 0x3?) #152

Closed hktalent closed 2 years ago

hktalent commented 2 years ago

code : https://github.com/hktalent/ScrapySite

sync.runtime_SemacquireMutex(0xc02c98fbf0?, 0x1f?, 0x3?)
        /usr/local/Cellar/go/1.18/libexec/src/runtime/sema.go:71 +0x25
sync.(*Mutex).lockSlow(0xc00026c0d0)
        /usr/local/Cellar/go/1.18/libexec/src/sync/mutex.go:162 +0x165
sync.(*Mutex).Lock(...)
        /usr/local/Cellar/go/1.18/libexec/src/sync/mutex.go:81
sync.(*RWMutex).Lock(0xc116261c360d6700?)
        /usr/local/Cellar/go/1.18/libexec/src/sync/rwmutex.go:139 +0x36
github.com/patrickmn/go-cache.(*cache).Set(0xc00026c0c0, {0xc02c656b70, 0x18}, {0x149cdc0?, 0xc0016a8f90}, 0x14aef00?)
        /Users/51pwn/go/pkg/mod/github.com/patrickmn/go-cache@v2.1.0+incompatible/cache.go:60 +0xe7
github.com/patrickmn/go-cache.(*cache).SetDefault(...)
        /Users/51pwn/go/pkg/mod/github.com/patrickmn/go-cache@v2.1.0+incompatible/cache.go:87
github.com/hktalent/scrapysite/lib.(*ScrapySite).DoResponse2Es(0xc0001d52f0, 0xc01f1e8440)
        /Users/51pwn/MyWork/ScrapySite/lib/scrapysite.go:235 +0x5ba
github.com/hktalent/scrapysite/lib.(*ScrapySite).OnResponse.func1(0x7?)
        /Users/51pwn/MyWork/ScrapySite/lib/scrapysite.go:306 +0x31
github.com/gocolly/colly/v2.(*Collector).handleOnResponse(0xc01f1e8440?, 0xc01f1e8440)
        /Users/51pwn/go/pkg/mod/github.com/gocolly/colly/v2@v2.1.0/colly.go:1035 +0x1d3
github.com/gocolly/colly/v2.(*Collector).fetch(0xc00016b340, {0x0?, 0x0?}, {0x1522f73, 0x3}, 0xb, {0x0?, 0x0}, 0x15e80a0?, 0xc00fbf92f0, ...)
        /Users/51pwn/go/pkg/mod/github.com/gocolly/colly/v2@v2.1.0/colly.go:674 +0x725
created by github.com/gocolly/colly/v2.(*Collector).scrape
        /Users/51pwn/go/pkg/mod/github.com/gocolly/colly/v2@v2.1.0/colly.go:574 +0x585
binhbo12456 commented 2 years ago

i have the same issue with you, goroutine suddenly increasing to a million, this is involved with OOM

goroutine 9405091 [semacquire]: sync.runtime_SemacquireMutex(0xc000e5fd14, 0x0, 0x1) github.com/patrickmn/go-cache.(*janitor).Run(0xc000d646c0, 0xc000133140) created by github.com/patrickmn/go-cache.runJanitor

hktalent commented 2 years ago

@binhbo12456 see https://github.com/hktalent/DNS_Server/blob/main/kvDb.go