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

Log is being applied on restart #7

Closed
kotyara85 opened this issue Aug 15, 2022 · 5 comments
Closed

Log is being applied on restart #7

kotyara85 opened this issue Aug 15, 2022 · 5 comments

Comments

@kotyara85
Copy link

Hello,
Is it an expected behavior?
After a node is restarted I see it fetches all the data from the leader
I'd expect it to get only the diff
Thanks

@shaj13
Copy link
Owner

shaj13 commented Sep 9, 2022

@kotyara85 depends on the node state, if when it restarted it lost durable storage then the leader will send out all logs again if there was a snapshot the leader will not send a diff it will send out a snapshot instead.

what was the term and index of the node before and after restart?

@kotyara85
Copy link
Author

@shaj13 sorry for the late reply, apply triggers on the local node and doesn't seem like affecting other nodes in the cluster. Does that mean I should somehow keep latest index and ignore all updates?
Thanks

@kotyara85
Copy link
Author

Oh, And how do I get a current index? Doesn't seem like there's any interfaces on the node object which allow to fetch taht
Thanks

@kotyara85
Copy link
Author

Ok, i figured out the snapshot situation
@shaj13 is there a way to notify if a current node was elected as a leader?
Thanks

@shaj13
Copy link
Owner

shaj13 commented Jul 9, 2023

@kotyara85

Great to know, can you tell what was the issue with snapshot situation ?

you can do the following to check if current node is leader:

func IsLeader(n *raft.Node) bool {
retrun n.Whoami() == n.Leader()
}

as well you can wrap it with a time.Ticker to report to a chan when its promoted to be a leader.

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

2 participants