bug(storage): cached blocks pin 2 MiB local-fs read buffers, so memory grows past the block cache's reported size
Author: matt-nannCreated Sep 28, 2026Updated Sep 28, 2026
Labelstype/bug
Describe the bug
On single-node with the local-disk state store, memory climbs steadily at near-zero load while the block cache reports under 1 MB used. For us it went from ~400 MB to ~2.4 GB in a day, with ~34 MB of state.
Cause:
- opendal's fs reader reads into a 2 MiB buffer and returns a slice of it.
SstableStore::get_block_responsecaches that slice as-is (Block::decode, no copy), so each small cached block keeps its whole 2 MiB buffer alive. The cache only counts the block's own size, so it never evicts.- On hosts with transparent huge pages set to
always, each of those buffers costs a full 2 MiB of RAM.
The prefetch path in the same file already copies ("copy again to avoid holding a large data in memory"). The single-block path doesn't.
Error message/log
No error; it's silent. A heap profile after 7 h attributed ~7.1 GB of 7.4 GB allocated to:
get_block_response -> OpendalObjectStore::read -> opendal Operator::read_with -> BytesMut::reserveTo Reproduce
docker run -d --name rw -p 4566:4566 -e MALLOC_CONF=thp:always \
risingwavelabs/risingwave:v2.7.2 single_node --store-directory /data --total-memory-bytes 8589934592ALTER SYSTEM SET barrier_interval_ms = 100;
CREATE TABLE evt (user_id BIGINT, timestamp TIMESTAMPTZ, raw_event JSONB) APPEND ONLY;
CREATE MATERIALIZED VIEW mv AS SELECT user_id FROM evt WHERE user_id = 1 AND timestamp > NOW() - INTERVAL '3600 seconds';
CREATE MATERIALIZED VIEW mv2 AS SELECT user_id FROM evt WHERE user_id = 1 AND timestamp > NOW() - INTERVAL '600 seconds';Watch Anonymous in /proc/$(pgrep -f bin/risingwave)/smaps_rollup. After 9 minutes: 807 MB with thp:always, 166 MB with thp:never, both on the same workload.
Expected behavior
Memory held by cached blocks stays bounded by the block cache capacity.
How did you deploy RisingWave?
Docker, single_node --store-directory /data, on Railway (x86-64, THP always).
The version of RisingWave
v2.7.2. The same code is on main.
Additional context
- Workaround:
MALLOC_CONF=thp:never. Our memory went from climbing to flat at ~340 MB. - Fix:
Block::decode_with_copy(block_data, uncompressed_capacity, true)inget_block_response. In our test it cut RAM under THP by ~100–250 MB
Source: risingwavelabs/risingwave