{"action":"created","issue":{"url":"https://api.github.com/repos/andrewjstone/rafter/issues/36","labels_url":"https://api.github.com/repos/andrewjstone/rafter/issues/36/labels{/name}","comments_url":"https://api.github.com/repos/andrewjstone/rafter/issues/36/comments","events_url":"https://api.github.com/repos/andrewjstone/rafter/issues/36/events","html_url":"https://github.com/andrewjstone/rafter/pull/36","id":70740772,"number":36,"title":"No longer an artificial delay between getting votes, and becoming a leader, for an initial configuration","user":{"login":"philipstears","id":813954,"avatar_url":"https://avatars.githubusercontent.com/u/813954?v=3","gravatar_id":"","url":"https://api.github.com/users/philipstears","html_url":"https://github.com/philipstears","followers_url":"https://api.github.com/users/philipstears/followers","following_url":"https://api.github.com/users/philipstears/following{/other_user}","gists_url":"https://api.github.com/users/philipstears/gists{/gist_id}","starred_url":"https://api.github.com/users/philipstears/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/philipstears/subscriptions","organizations_url":"https://api.github.com/users/philipstears/orgs","repos_url":"https://api.github.com/users/philipstears/repos","events_url":"https://api.github.com/users/philipstears/events{/privacy}","received_events_url":"https://api.github.com/users/philipstears/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-04-24T17:07:12Z","updated_at":"2015-05-11T23:20:04Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/andrewjstone/rafter/pulls/36","html_url":"https://github.com/andrewjstone/rafter/pull/36","diff_url":"https://github.com/andrewjstone/rafter/pull/36.diff","patch_url":"https://github.com/andrewjstone/rafter/pull/36.patch"},"body":"We discovered in testing, that if you've got a brand new cluster, and you call `set_config(...)` on the node you wish to be the leader of the new cluster, that it doesn't become the leader as soon as it has gathered enough votes. It will end up waiting whatever the remainder of the `election_timeout()`  is.\r\n\r\nThis is because `become_leader(...)` when `init_config` is not `complete` doesn't really do anything, instead it waits for whatever timer is currently set-up to trigger a `timeout` in the leader state.\r\n\r\nI think the best thing to do, and what I've implemented, is to have `become_leader(...)` do the work that was originally done in special cases of `leader(timeout, ...)`.\r\n\r\nThere is one thing I'm unsure about, which is the behaviour when `init_config` is `undefined`, which can happen if a node comes up with no log, and then is joined to the cluster by another node. If the leader of the cluster at that point becomes unavailable, the node with `init_config` of `undefined` can become a candidate, and then become the leader. In this case rafter is not adding a no-op entry to the log, which I'm pretty sure isn't the right thing to do - so I've made that case basically the same as when `init_config` is `complete`. Hopefully that's the right thing to do."},"comment":{"url":"https://api.github.com/repos/andrewjstone/rafter/issues/comments/101072783","html_url":"https://github.com/andrewjstone/rafter/pull/36#issuecomment-101072783","issue_url":"https://api.github.com/repos/andrewjstone/rafter/issues/36","id":101072783,"user":{"login":"andrewjstone","id":466937,"avatar_url":"https://avatars.githubusercontent.com/u/466937?v=3","gravatar_id":"","url":"https://api.github.com/users/andrewjstone","html_url":"https://github.com/andrewjstone","followers_url":"https://api.github.com/users/andrewjstone/followers","following_url":"https://api.github.com/users/andrewjstone/following{/other_user}","gists_url":"https://api.github.com/users/andrewjstone/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewjstone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewjstone/subscriptions","organizations_url":"https://api.github.com/users/andrewjstone/orgs","repos_url":"https://api.github.com/users/andrewjstone/repos","events_url":"https://api.github.com/users/andrewjstone/events{/privacy}","received_events_url":"https://api.github.com/users/andrewjstone/received_events","type":"User","site_admin":false},"created_at":"2015-05-11T23:20:04Z","updated_at":"2015-05-11T23:20:04Z","body":"Hi @philipstears, \r\n\r\nI'm looking over this commit now. I don't believe that a candidate can arise with `init_config =:= undefined` . The reason is that a follower will never have a vote if their config is blank which will be true if they have an empty log and another leader got elected but didn't replicate the config entry yet. In that case I believe that only that original leader can be re-elected. If that leader is permanently out of commission the user will have to send a `set_config` command to another node to make it a candidate.\r\n\r\nI'm still looking over the code for safety. It appears to be a slight perf optimization and safe. It also passes  the tests. I'll let you know shortly."}}