{"action":"created","issue":{"url":"https://api.github.com/repos/lasp-lang/partisan/issues/156","repository_url":"https://api.github.com/repos/lasp-lang/partisan","labels_url":"https://api.github.com/repos/lasp-lang/partisan/issues/156/labels{/name}","comments_url":"https://api.github.com/repos/lasp-lang/partisan/issues/156/comments","events_url":"https://api.github.com/repos/lasp-lang/partisan/issues/156/events","html_url":"https://github.com/lasp-lang/partisan/pull/156","id":305654726,"number":156,"title":"Fixes to membership state when nodes explicitly leave (partisan_default_peer_service)","user":{"login":"aramallo","id":195590,"avatar_url":"https://avatars1.githubusercontent.com/u/195590?v=4","gravatar_id":"","url":"https://api.github.com/users/aramallo","html_url":"https://github.com/aramallo","followers_url":"https://api.github.com/users/aramallo/followers","following_url":"https://api.github.com/users/aramallo/following{/other_user}","gists_url":"https://api.github.com/users/aramallo/gists{/gist_id}","starred_url":"https://api.github.com/users/aramallo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aramallo/subscriptions","organizations_url":"https://api.github.com/users/aramallo/orgs","repos_url":"https://api.github.com/users/aramallo/repos","events_url":"https://api.github.com/users/aramallo/events{/privacy}","received_events_url":"https://api.github.com/users/aramallo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2018-03-15T17:44:49Z","updated_at":"2018-03-21T21:57:12Z","closed_at":null,"author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/lasp-lang/partisan/pulls/156","html_url":"https://github.com/lasp-lang/partisan/pull/156","diff_url":"https://github.com/lasp-lang/partisan/pull/156.diff","patch_url":"https://github.com/lasp-lang/partisan/pull/156.patch"},"body":"I found a number of issues when using `partisan_default_peer_service_manager:leave/0`.\r\n\r\n\r\n* In `partisan_default_peer_service_manager:handle_message({receive_state, ...}, ...)` the functions `establish_connections/4` and `do_gossip/2` where called with the previous membership Set as opposed to the newly merged Set. \r\n* In `partisan_default_peer_service_manager:handle_call({leave, Node}, ...)` I added a call to `partisan_peer_service_events:update(EmptyMembership),` to fix an issue where peer service users would not get notified of the membership change. This might look redundant as the sever stops right after that call, but Plumtree for example will miss the update and keep and incorrect view of the `broadcast_members`.\r\n* Removed a redundant call to `without_me` in `partisan_default_peer_service_manager:establish_connections/4`.\r\n\r\n\r\n\r\n### Outstanding issues\r\nIn a two node cluster (I use as example our app called `plum_db`), after node `plum_db2` leaves the cluster with `partisan_default_peer_service_manager:leave/0`, we still end up with an inconsistent connection state.\r\n\r\n```erlang\r\n(plum_db2@127.0.0.1)6> partisan_default_peer_service_manager:connections().\r\n{ok,{dict,0,16,16,8,80,48,\r\n          {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},\r\n          {{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]}}}}\r\n```\r\n\r\nWhich is correct, but `plum_db1` still has a connection to `plum_db2` (??).\r\n\r\n```erlang\r\n(plum_db1@127.0.0.1)4> partisan_default_peer_service_manager:connections().\r\n{ok,{dict,1,16,16,8,80,48,\r\n          {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},\r\n          {{[],[],[],[],[],[],[],\r\n            [[#{channels => [undefined],\r\n                listen_addrs =>\r\n                    [#{ip => {127,0,0,...},port => 51974}],\r\n                name => 'plum_db2@127.0.0.1',parallelism => 1},\r\n              {#{ip => {127,0,0,1},port => 51974},\r\n               undefined,<0.847.0>}]],\r\n            [],[],[],[],[],[],[],[]}}}}\r\n```\r\n\r\nI think the issue is that we need to manually kill the connections on the `handle_call({leave, Node},...)` call? with a call to `partisan_util:may_disconnect/2` ?\r\n\r\nI will create an Issue if this last thing makes sense and try to find a solution later.\r\n"},"comment":{"url":"https://api.github.com/repos/lasp-lang/partisan/issues/comments/375109358","html_url":"https://github.com/lasp-lang/partisan/pull/156#issuecomment-375109358","issue_url":"https://api.github.com/repos/lasp-lang/partisan/issues/156","id":375109358,"user":{"login":"aramallo","id":195590,"avatar_url":"https://avatars1.githubusercontent.com/u/195590?v=4","gravatar_id":"","url":"https://api.github.com/users/aramallo","html_url":"https://github.com/aramallo","followers_url":"https://api.github.com/users/aramallo/followers","following_url":"https://api.github.com/users/aramallo/following{/other_user}","gists_url":"https://api.github.com/users/aramallo/gists{/gist_id}","starred_url":"https://api.github.com/users/aramallo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aramallo/subscriptions","organizations_url":"https://api.github.com/users/aramallo/orgs","repos_url":"https://api.github.com/users/aramallo/repos","events_url":"https://api.github.com/users/aramallo/events{/privacy}","received_events_url":"https://api.github.com/users/aramallo/received_events","type":"User","site_admin":false},"created_at":"2018-03-21T21:57:12Z","updated_at":"2018-03-21T21:57:12Z","author_association":"NONE","body":"@cmeiklejohn I should probably close this PR and open a new one with more fixes including test cases. "}}
{"actor":{"display_login":"aramallo"}}