shaj13 / raft Goto Github PK
View Code? Open in Web Editor NEWraft is a golang library that provides a simple, clean, and idiomatic implementation of the Raft consensus protocol
License: MIT License
raft is a golang library that provides a simple, clean, and idiomatic implementation of the Raft consensus protocol
License: MIT License
Hello @shaj13 @aderouineau and @fredpetersen
I would like you to help provide guides on how to use this library on kubernetes where one can make use of the k8 api to discover pods and start a cluster.
Thanks
Hi @shaj13 ,
Looks like current gprc protos do not expose cluster management apis, for example remove failed node from the cluster.
Are there any plans on doing so?
Thank you
Hello @shaj13
Thanks for this great library. It has helped a lot understanding the etcd raft. However I would like to know whether this library has been used in production already.
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
Hello @shaj13 can you please provide an example of data sharding and gossip that you stated in the multi-raft example?
Thanks
Hi there and thanks for sharing this project. I'm keen to introduce Raft into one of my projects in which there is a predefined cluster. During boot I'm getting the follower error on 2 of the three nodes:
panic: raft.membership: attempted to send msg to local member; should never happen
Here is the relevant code
func raftInit() {
raftgrpc.Register(
raftgrpc.WithDialOptions(grpc.WithInsecure()),
)
fsm = newstateMachine()
node = raft.NewNode(fsm, transport.GRPC)
raftServer = grpc.NewServer()
raftgrpc.RegisterHandler(raftServer, node.Handler())
m1 := raft.RawMember{ID: 1, Address: "host1:8081"}
m2 := raft.RawMember{ID: 2, Address: "host2:8081"}
m3 := raft.RawMember{ID: 3, Address: "host3:8081"}
go func() {
lis, err := net.Listen("tcp", ":8081")
if err != nil {
log.Fatal(err)
}
err = raftServer.Serve(lis)
if err != nil {
log.Fatal(err)
}
}()
go func() {
err := node.Start(raft.WithInitCluster(), raft.WithMembers(m1, m2, m3) )
if err != nil {
log.Fatal(err)
}
}()
}
Not sure if this is misconfigured on my side or if there's an issue here. Would greatly appreciate you assistance.
Is it possible to remove dead node from the cluster?
RemoveMember seems to be just marking node as removed
Thanks
I want to implement a distributed KV system with data sharding based on consistent hash , which involves the need to re-shard and transfer the cluster data after the cluster leader changes.I see that etcd does not provide a notification mechanism, but hashiCorp/raft does provide LeaderCh and NotifyCh to actively notify the application layer that the leader has changed.
In the implementation of this system, in addition to the above functions, a preVote function is required, but this function is not implemented in hashicorp/raft. So eventually I have to resort to etcd/raft. So I'd like to ask if you have that notification mechanism in your implementation of raft, or if there are other better suggestions
Hello I observed the node id are integer meanwhile using platform like kubernetes we can make use of the node name. Any recommendation on this will be helpful
Hello @shaj13
I am getting the following error:
ERROR: raft.membership: sending message to member 24669d2775c8b223: rpc error: code = Unimplemented desc = unexpected HTTP status code received from server: 404 (Not Found); transport: received unexpected content-type "text/plain; charset=utf-8"
I am running the application on k8 with a replica of 2.
These are the logs from the two Pods:
Pod-1:
{"level":"debug","ts":1683374970.9820142,"msg":"raft node URL=:3100"}
{"level":"debug","ts":1683374972.0948684,"msg":"kubernetes has discovered 1 nodes"}
2023/05/06 12:09:32 INFO: 61cca80dec1edadd switched to configuration voters=()
2023/05/06 12:09:32 INFO: 61cca80dec1edadd became follower at term 0
2023/05/06 12:09:32 INFO: newRaft 61cca80dec1edadd [peers: [], term: 0, commit: 0, applied: 0, lastindex: 0, lastterm: 0]
2023/05/06 12:09:32 INFO: 61cca80dec1edadd became follower at term 1
2023/05/06 12:09:32 INFO: 61cca80dec1edadd switched to configuration voters=(7047192294677469917)
2023/05/06 12:09:32 INFO: 61cca80dec1edadd switched to configuration voters=(7047192294677469917)
2023/05/06 12:09:33 INFO: 61cca80dec1edadd is starting a new election at term 1
2023/05/06 12:09:33 INFO: 61cca80dec1edadd became candidate at term 2
2023/05/06 12:09:33 INFO: 61cca80dec1edadd received MsgVoteResp from 61cca80dec1edadd at term 2
2023/05/06 12:09:33 INFO: 61cca80dec1edadd became leader at term 2
2023/05/06 12:09:33 INFO: raft.node: 61cca80dec1edadd elected leader 61cca80dec1edadd at term 2
2023/05/06 12:10:00 INFO: 61cca80dec1edadd switched to configuration voters=(2622956625795265059 7047192294677469917)
2023/05/06 12:10:01 ERROR: raft.membership: sending message to member 24669d2775c8b223: rpc error: code = Unimplemented desc = unexpected HTTP status code received from server: 404 (Not Found); transport: received unexpected content-type "text/plain; charset=utf-8"
Pod-2:
{"level":"debug","ts":1683374999.3820262,"msg":"raft node URL=:3100"}
{"level":"debug","ts":1683375000.8786376,"msg":"kubernetes has discovered 2 nodes"}
2023/05/06 12:10:01 INFO: 24669d2775c8b223 switched to configuration voters=()
2023/05/06 12:10:01 INFO: 24669d2775c8b223 became follower at term 0
2023/05/06 12:10:01 INFO: newRaft 24669d2775c8b223 [peers: [], term: 0, commit: 0, applied: 0, lastindex: 0, lastterm: 0]
2023/05/06 12:10:01 INFO: 24669d2775c8b223 became follower at term 1
2023/05/06 12:10:01 INFO: 24669d2775c8b223 switched to configuration voters=(2622956625795265059)
2023/05/06 12:10:01 INFO: 24669d2775c8b223 switched to configuration voters=(2622956625795265059 7047192294677469917)
2023/05/06 12:10:01 INFO: 24669d2775c8b223 switched to configuration voters=(2622956625795265059 7047192294677469917)
2023/05/06 12:10:01 INFO: 24669d2775c8b223 switched to configuration voters=()
2023/05/06 12:10:01 INFO: 24669d2775c8b223 became follower at term 0
2023/05/06 12:10:01 INFO: newRaft 24669d2775c8b223 [peers: [], term: 0, commit: 0, applied: 0, lastindex: 0, lastterm: 0]
I am sure I am doing something wrong
I found there's a critical error in transport.Dialer
while using transport.HTTP
instead of transport.GRPC
. The address parameter is like 127.0.0.1:8080
. rafthttp.Dialer
while pass this address to rafthttp.client
thus problems will happen when the leader is trying to communicate with followers. rafthttp.client.Message
proceed client request via http.NewRequestWithContext
in rafthttp.client.requestProto
method. Because the scheme of URL is missing from which we passed (127.0.0.1:8080) in the dialer.
More detail please see net/url.Parse. URL schema is required.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.