Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

raft: paginate the unapplied config changes scan #530

Merged
merged 2 commits into from
Oct 17, 2023

Conversation

overvenus
Copy link
Member

@overvenus overvenus commented Oct 16, 2023

Fix potentially unlimited memory usage spike possible in raft.hup() which reads
all unapplied committed entries in order to check that there are no unapplied
config changes. This PR paginates this scan so that the spike is limited to
MaxCommittedSizePerReady. It also terminates the scan early if a config change
has been found.

It is ported from etcd-io/raft#32.

Signed-off-by: Neil Shen <overvenus@gmail.com>
Copy link
Member

@Connor1996 Connor1996 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@gengliqi gengliqi left a comment

Choose a reason for hiding this comment

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

LGTM

src/raft_log.rs Outdated Show resolved Hide resolved
Signed-off-by: Neil Shen <overvenus@gmail.com>
@overvenus overvenus force-pushed the pageinate-scan-conf-change branch from 87cdb8a to 83c5c43 Compare October 17, 2023 09:13
@overvenus overvenus merged commit f60fb9e into master Oct 17, 2023
5 checks passed
tisonkun added a commit to tisonkun/mephisto-archive that referenced this pull request Oct 18, 2023
Fix potentially unlimited memory usage spike possible in raft.hup() which reads
all unapplied committed entries in order to check that there are no unapplied
config changes. This PR paginates this scan so that the spike is limited to
MaxCommittedSizePerReady. It also terminates the scan early if a config change
has been found.

It is ported from etcd-io/raft#32.
It is ported from tikv/raft-rs#530.

Signed-off-by: tison <wander4096@gmail.com>
tisonkun added a commit to tisonkun/mephisto-archive that referenced this pull request Oct 18, 2023
Fix potentially unlimited memory usage spike possible in raft.hup()
which reads all unapplied committed entries in order to check that there
are no unapplied config changes. This PR paginates this scan so that the
spike is limited to MaxCommittedSizePerReady. It also terminates the
scan early if a config change has been found.

It is ported from etcd-io/raft#32.

It is ported from tikv/raft-rs#530.

Signed-off-by: tison <wander4096@gmail.com>
overvenus added a commit to overvenus/tikv that referenced this pull request Oct 20, 2023
Before start election, raft-rs has to check if there is any unapplied conf change
entry. In the current implementation, this needs to scan logs from
[unapplied_index, committed_index]. It essentially takes unbounded memory when
raft peers that has many unapplied logs.
To fix the issue, TiKV can paginate scan raft log which has a fixed memory usage
upper bound.

Cc tikv/raft-rs#530

Signed-off-by: Neil Shen <overvenus@gmail.com>
ti-chi-bot pushed a commit to ti-chi-bot/tikv that referenced this pull request Oct 23, 2023
Before start election, raft-rs has to check if there is any unapplied conf change
entry. In the current implementation, this needs to scan logs from
[unapplied_index, committed_index]. It essentially takes unbounded memory when
raft peers that has many unapplied logs.
To fix the issue, TiKV can paginate scan raft log which has a fixed memory usage
upper bound.

Cc tikv/raft-rs#530

Signed-off-by: Neil Shen <overvenus@gmail.com>
@tisonkun tisonkun deleted the pageinate-scan-conf-change branch November 15, 2023 06:38
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.

4 participants