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

Incorrect condition check in getEntry(long index). #51

Open
liang636600 opened this issue Oct 14, 2024 · 0 comments
Open

Incorrect condition check in getEntry(long index). #51

liang636600 opened this issue Oct 14, 2024 · 0 comments

Comments

@liang636600
Copy link

Hi, @wenweihu86 , I think there is an issue with the condition that directly returns null when endIndex == 0. This is because there is a type of Segment file named open-i, which typically indicates that the Segment can continue accepting new entries, and their endIndex is represented as 0. If such a condition is set, when the function's input index falls within a Segment like open-i, it will only return null, which I think is inappropriate.

public RaftProto.LogEntry getEntry(long index) {
if (startIndex == 0 || endIndex == 0) {
return null;
}

Suggested fix: if (startIndex == 0 || endIndex == 0) => if (startIndex == 0)

I'm looking forward to your confirmation, and would be happy to help fix the issue if needed.

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

No branches or pull requests

1 participant