Skip to content

[FIXED] Cache and limit pending entries#7233

Merged
neilalexander merged 1 commit intomainfrom
maurice/infinite-pae
Aug 29, 2025
Merged

[FIXED] Cache and limit pending entries#7233
neilalexander merged 1 commit intomainfrom
maurice/infinite-pae

Conversation

@MauriceVanVeen
Copy link
Copy Markdown
Member

The Raft group leader would cache all pending entries in n.pae, allowing it to grow infinitely when applies are slower than the proposals themselves. This PR extracts that logic so the leader and follower caching paths are the same, as well as applying the same limits.

Signed-off-by: Maurice van Veen github@mauricevanveen.com

@MauriceVanVeen MauriceVanVeen requested a review from a team as a code owner August 29, 2025 08:58
server/raft.go Outdated
// cachePendingEntry saves append entries in memory for faster processing during applyCommit.
// Only save so many however to avoid memory bloat.
func (n *raft) cachePendingEntry(ae *appendEntry) {
if l := len(n.pae); l <= paeDropThreshold {
Copy link
Copy Markdown
Member

@neilalexander neilalexander Aug 29, 2025

Choose a reason for hiding this comment

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

I realise it’s pedantic but this will put us one above paeDropThreshold, although it probably doesn’t matter much. Might make sense to put this to < and then make the log condition >=.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done

Signed-off-by: Maurice van Veen <github@mauricevanveen.com>
Copy link
Copy Markdown
Member

@neilalexander neilalexander left a comment

Choose a reason for hiding this comment

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

LGTM

@neilalexander neilalexander merged commit 835c0eb into main Aug 29, 2025
48 checks passed
@neilalexander neilalexander deleted the maurice/infinite-pae branch August 29, 2025 09:43
neilalexander added a commit that referenced this pull request Sep 8, 2025
Includes the following:
- #7200
- #7201
- #7202
- #7209
- #7210
- #7211
- #7213
- #7212
- #7216
- #7217
- #7230
- #7239
- #7246
- #7248
-
8241a15,
specifically delayed errors that are not JS API errors
- #7158 (not containing
2.12-specific changes)
- #7233
- #7255
- #7249
- #7259
- #7265
- #7273 (not including Go
1.25.x)
- #7258
- #7222

Signed-off-by: Maurice van Veen <github@mauricevanveen.com>
Signed-off-by: Neil Twigg <neil@nats.io>
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.

2 participants