dgraph-io / badger

Fast key-value DB in Go.
https://dgraph.io/badger
Apache License 2.0
13.48k stars 1.15k forks source link

fix(table cache) block cache logic for table with no compression #2022

Open hugy718 opened 7 months ago

hugy718 commented 7 months ago

Problem

Fixes #2021.

The problem is in the block() function in table.go. blk.data takes a slice of the t.Data. If there is no decryption or decompression, it will hold this slice and added to the cache, which means it will always hold a reference of t.Data. That will also preventing GC of the mmap file buffer, so long as a block of it is in cache.

Solution

Make a copy of the block data, when no decryption nor compression.

netlify[bot] commented 7 months ago

Deploy Preview for badger-docs ready!

Name Link
Latest commit d01e622973593d0a2abdcbe177a6770ce063984b
Latest deploy log https://app.netlify.com/sites/badger-docs/deploys/652e5431236ac00008d3dbc0
Deploy Preview https://deploy-preview-2022--badger-docs.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.