{"action":"closed","issue":{"url":"https://api.github.com/repos/docker/swarmkit/issues/2241","repository_url":"https://api.github.com/repos/docker/swarmkit","labels_url":"https://api.github.com/repos/docker/swarmkit/issues/2241/labels{/name}","comments_url":"https://api.github.com/repos/docker/swarmkit/issues/2241/comments","events_url":"https://api.github.com/repos/docker/swarmkit/issues/2241/events","html_url":"https://github.com/docker/swarmkit/issues/2241","id":235325123,"number":2241,"title":"Raft lock held while saving root CA","user":{"login":"aaronlehmann","id":10601430,"avatar_url":"https://avatars3.githubusercontent.com/u/10601430?v=4","gravatar_id":"","url":"https://api.github.com/users/aaronlehmann","html_url":"https://github.com/aaronlehmann","followers_url":"https://api.github.com/users/aaronlehmann/followers","following_url":"https://api.github.com/users/aaronlehmann/following{/other_user}","gists_url":"https://api.github.com/users/aaronlehmann/gists{/gist_id}","starred_url":"https://api.github.com/users/aaronlehmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aaronlehmann/subscriptions","organizations_url":"https://api.github.com/users/aaronlehmann/orgs","repos_url":"https://api.github.com/users/aaronlehmann/repos","events_url":"https://api.github.com/users/aaronlehmann/events{/privacy}","received_events_url":"https://api.github.com/users/aaronlehmann/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-06-12T18:37:22Z","updated_at":"2017-08-03T18:58:02Z","closed_at":"2017-08-03T18:58:02Z","body":"I noticed this code:\r\n\r\n```go\r\n        updates, cancel, err := store.ViewAndWatch(\r\n                s.store,\r\n                func(readTx store.ReadTx) error {\r\n                        clusters, err := store.FindClusters(readTx, store.ByName(store.DefaultClusterName))\r\n                        if err != nil {\r\n                                return err\r\n                        }\r\n                        if len(clusters) != 1 {\r\n                                return errors.New(\"could not find cluster object\")\r\n                        }\r\n                        s.UpdateRootCA(ctx, clusters[0]) // call once to ensure that the join tokens are always set\r\n                        nodes, err = store.FindNodes(readTx, store.All)\r\n                        return err\r\n                },\r\n                api.EventCreateNode{},\r\n                api.EventUpdateNode{},\r\n                api.EventDeleteNode{},\r\n        )\r\n```\r\n\r\n`s.UpdateRootCA` does some file I/O when it saves the root CA cert. It also acquires another lock.\r\n\r\n`ViewAndWatch` holds the raft lock to give a strong consistency guarantee that the caller won't receive events whose effects were already visible in the `View` portion, but I'm not sure this code needs this guarantee.\r\n\r\ncc @cyli"}}
{"actor":{"display_login":"cyli"}}