Memory leak using Caddy Souin cache + Badger #890
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
The report names Badger’s skl.newArena and Ristretto’s z.Calloc in Go heap profiles, but gives no reproduction steps or Badger-specific configuration beyond the Caddy cache setup. Start by identifying whether either allocation grows under a reproducible workload and checking the relevant Badger allocation paths. Done means a reproducible cause and fix or guidance that establishes the growth is expected.
Written by the indexing model from the issue text.
Description
Describe the bug
Not sure where's best to report this apparent memory leak. Using Caddy cache module with badger storage, writing to disk under /var/cache rather than in-memory. Is there other useful info I can share?
Go heap profiling yesterday:
flat flat% sum% cum cum%
332.80MB 87.02% 87.02% 332.80MB 87.02% github.com/dgraph-io/badger/v4/skl.newArena
22.55MB 5.90% 92.91% 22.55MB 5.90% github.com/dgraph-io/badger/v4/y.SafeCopy
6.52MB 1.70% 94.62% 6.52MB 1.70% github.com/dgraph-io/ristretto/v2/z.Calloc
Go heap profiling today:
flat flat% sum% cum cum%
332.80MB 53.37% 53.37% 332.80MB 53.37% github.com/dgraph-io/badger/v4/skl.newArena
258.34MB 41.43% 94.80% 258.34MB 41.43% github.com/dgraph-io/ristretto/v2/z.Calloc (inline)
8MB 1.28% 96.08% 8MB 1.28% github.com/pierrec/lz4/v4/internal/lz4block.init.func6
7.12MB 1.14% 97.22% 7.12MB 1.14% bytes.growSlice
0.85MB 0.14% 97.36% 4.49MB 0.72% github.com/darkweak/souin/pkg/surrogate/providers.(*baseStorage).storeTag
0 0% 97.36% 3.26MB 0.52% bytes.(*Buffer).Grow
0 0% 97.36% 7.12MB 1.14% bytes.(*Buffer).grow
0 0% 97.36% 39.98MB 6.41% github.com/caddyserver/caddy/v2/modules/caddyhttp.(*Server).ServeHTTP
0 0% 97.36% 39.98MB 6.41% github.com/caddyserver/caddy/v2/modules/caddyhttp.(*Server).enforcementHandler
0 0% 97.36% 39.98MB 6.41% github.com/caddyserver/caddy/v2/modules/caddyhttp.(*Server).serveHTTP
Caddy profiing:
| Count | Profile |
|---|---|
| 7092 | allocs |
| 0 | block |
| 0 | cmdline |
| 77* | goroutine |
| 0 | goroutineleak |
| 7092** | heap |
| 0 | mutex |
| 0 | profile |
| 0 | symbol |
| 7 | threadcreate |
| 0 | trace |
/* goes up and down
/** increases pretty constantly
To Reproduce
Unclear. My badger configuration in Caddyfile is as follows:
cache {
timeout {
backend 60s
cache 2s
}
allowed_http_verbs GET
key {
hash
disable_query
}
ttl 1h
default_cache_control max-age=3600
badger {
path /var/cache/badger/site_cache
}
}
Expected behavior
Normal memory usage, without heap count constantly increasing.
Screenshots
If applicable, add screenshots to help explain your problem.
Environment
- OS: Linux
- Language Go
Additional context
Add any other context about the problem here.
- Dominant language
- Go
- Stars
- 15.8k
- Forks
- 1.4k
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dgraph-io/badger
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Iterator with SinceTs reads the tables whose max version equals SinceTsPossibly taken @BenSouchet claimed this 25 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
kind/bug Stale
Difficulty 2/5 Under an hour Newbie friendliness 75/100
-
Missing value log fsync on MemTableFlush and vlog rotation results in dangling value pointers after a crashPossibly taken @sli67 claimed this today. Open
Difficulty 3/5 1-2 days Newbie friendliness 20/100
-
Missing syncDir on value log rotation and L0 table flush breaks crash consistencyPossibly taken @hcrosse claimed this 4 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 45/100
All issues in dgraph-io/badger
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
hivecommons/hive#19912 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
siyuan-note/siyuan#21692 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
rudderlabs/rudder-server#7641 · 1 comment ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
ossf/package-analysis#1222 ·
Maintainers usually reply within 1 day