Code Monkey home page Code Monkey logo

raft's People

Contributors

aderouineau avatar dependabot[bot] avatar fredpetersen avatar shaj13 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

raft's Issues

Extend grpc api

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

Production fitness

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.

TODO

TODO

  • add tcp rpc
  • check the conf change v2
  • Repair wall
  • add more logs.

Log is being applied on restart

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

Nodes try to self connect when given predefined config

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.

Remove dead node

Is it possible to remove dead node from the cluster?
RemoveMember seems to be just marking node as removed
Thanks

How do I get notified of the change of leader?

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

Got rpc error: code = Unimplemented desc = unexpected HTTP status code received from server: 404 (Not Found)

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

example cannot work under http protocol

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.