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

Made newTerm operation idempotent instead of returning AlreadyFenced error #602

Merged
merged 1 commit into from
Jan 25, 2025

Conversation

merlimat
Copy link
Collaborator

Fixes #596

@@ -267,16 +267,6 @@ func (fc *followerController) NewTerm(req *proto.NewTermRequest) (*proto.NewTerm
slog.Int64("new-term", req.Term),
)
return nil, common.ErrorInvalidTerm
} else if req.Term == fc.term && fc.status != proto.ServingStatus_FENCED {
Copy link
Member

Choose a reason for hiding this comment

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

If they are same term, how about return the lastEntryId, err := getLastEntryIdInWal(fc.wal) directly?

Copy link
Member

@mattisonchao mattisonchao left a comment

Choose a reason for hiding this comment

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

LGTM, and I think we can also make the addFollower as idempotent to avoid extra error handling.

@merlimat merlimat merged commit 10a6992 into streamnative:main Jan 25, 2025
5 checks passed
@merlimat merlimat deleted the already-fenced branch January 25, 2025 01:17
mattisonchao added a commit that referenced this pull request Jan 25, 2025
### Motivation

Align the behaviour as #602. we can also make the `addFollower`
idempotent to avoid extra error handling.

---------

Co-authored-by: Matteo Merli <[email protected]>
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.

bug: panic: runtime error: invalid memory address or nil pointer dereference
2 participants