Skip to content

Conversation

@swuferhong
Copy link
Contributor

Purpose

Linked issue: close #1950

When testing the stability of PrimaryKey tables, a frequent issue arises where exceptionally high write traffic peaks cause delayed log synchronization. This leads to continuous accumulation in the KV's PrewriteBuffer. Since the current PrewriteBuffer lacks a back-pressure mechanism, has no memory cap, and utilizes JVM heap memory, it can easily trigger OOM errors, resulting in TabletServer crashes.

In this pr, we will introduce an off-heap shared memory cache to share memory between different Replica.

Brief change log

Tests

API and Format

Documentation

@swuferhong swuferhong force-pushed the pre-writebuffer-cache branch from 0f6f035 to 7e693a9 Compare November 10, 2025 01:33
import static org.apache.fluss.utils.concurrent.LockUtils.inLock;

/** a shared off-heap memory pool for {@link KvPreWriteBuffer} of different tableBucket. */
public class KvPreWriteBufferMemoryPool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious about why not to reuse the LazyMemorySegmentPool?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LazyMemorySegmentPool uses a large memory chunks (page size), for example, the default value of 128 KB. Personally, I don't think it's necessary to set it this large, because a single value of kv record here isn't as big as a recordBatch.

@swuferhong swuferhong force-pushed the pre-writebuffer-cache branch from 7e693a9 to e4e96b1 Compare December 18, 2025 05:45
@swuferhong swuferhong closed this Dec 18, 2025
@swuferhong swuferhong deleted the pre-writebuffer-cache branch December 18, 2025 11:57
@swuferhong swuferhong restored the pre-writebuffer-cache branch December 19, 2025 02:35
@swuferhong swuferhong reopened this Dec 19, 2025
@swuferhong swuferhong force-pushed the pre-writebuffer-cache branch 2 times, most recently from 4d5d7c6 to 7560223 Compare December 19, 2025 02:42
@swuferhong swuferhong force-pushed the pre-writebuffer-cache branch from 7560223 to 4475391 Compare December 21, 2025 03:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Introduce a shared memory cache for PrewriteBuffer between different replica

2 participants