{"action":"closed","number":35,"pull_request":{"url":"https://api.github.com/repos/ncw/swift/pulls/35","id":29863849,"html_url":"https://github.com/ncw/swift/pull/35","diff_url":"https://github.com/ncw/swift/pull/35.diff","patch_url":"https://github.com/ncw/swift/pull/35.patch","issue_url":"https://api.github.com/repos/ncw/swift/issues/35","number":35,"state":"closed","locked":false,"title":"fix race between (*ObjectCreateFile).Write() and (*Connection).ObjectCreate()'s requesting goroutine","user":{"login":"encryptio","id":67937,"avatar_url":"https://avatars.githubusercontent.com/u/67937?v=3","gravatar_id":"","url":"https://api.github.com/users/encryptio","html_url":"https://github.com/encryptio","followers_url":"https://api.github.com/users/encryptio/followers","following_url":"https://api.github.com/users/encryptio/following{/other_user}","gists_url":"https://api.github.com/users/encryptio/gists{/gist_id}","starred_url":"https://api.github.com/users/encryptio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/encryptio/subscriptions","organizations_url":"https://api.github.com/users/encryptio/orgs","repos_url":"https://api.github.com/users/encryptio/repos","events_url":"https://api.github.com/users/encryptio/events{/privacy}","received_events_url":"https://api.github.com/users/encryptio/received_events","type":"User","site_admin":false},"body":"I had a deadlock issue in a virtualized testing environment (and thus with random latency spikes for both IO and CPU) while creating objects. By the time I realize it's locked up, the only goroutine running anything of note has this as its head of stack trace:\r\n\r\n    2 @ 0x41f639 0x41f6bb 0x433700 0x47f8bd 0x4f271f 0x4f2b8f 0x575c4c 0x4f16eb 0x4bb8e3 0x4bded4 0x4bbb38 0x4b9ee3 0x4b9d78 0x4bcc12 0x4bbb38 0x4ba660 0x4ba413 0x4bd201 0x409f62 0x40a3c6 0x409a6e 0x40998c 0x409659 0x406ae8 0x405ef5 0x40164f 0x40119b 0x40a947 0x41f8d0\r\n    #       0x433700        sync.runtime_Syncsemacquire+0xc0                                                        /home/croll/local/go-1.3.3/src/pkg/runtime/sema.goc:257\r\n    #       0x47f8bd        sync.(*Cond).Wait+0x9d                                                                  /home/croll/local/go-1.3.3/src/pkg/sync/cond.go:62\r\n    #       0x4f271f        io.(*pipe).write+0x21f                                                                  /home/croll/local/go-1.3.3/src/pkg/io/pipe.go:94\r\n    #       0x4f2b8f        io.(*PipeWriter).Write+0x5f                                                             /home/croll/local/go-1.3.3/src/pkg/io/pipe.go:161\r\n    #       0x575c4c        github.com/ncw/swift.(*ObjectCreateFile).Write+0x1cc                                    /$GOPATH/github.com/ncw/swift/swift.go:1062\r\n    #       0x4f16eb        io.Copy+0x27b                                                                           /home/croll/local/go-1.3.3/src/pkg/io/io.go:355\r\n    #       0x4bb8e3        mycompany/myproject/resource.swiftResource.Upload+0x503        /mycompany/myproject/resource/swift.go:160\r\n    ...\r\n\r\nI think this deadlock is caused by this race:\r\n\r\nIf `(*ObjectCreateFile).Write()` fails its nonblocking read on `file.done` (and thus passes through), it sends the byte string over to the pipeWriter half and to the hasher.\r\nIf during the same time, the request finishes unexpectedly (for example, due to a timeout), there's a time period in between that and the helper goroutine of `(*Connection).ObjectCreate()`'s call to `close(file.done)`. The `Write()` call has already made its check on `file.done`, and thus blocks forever waiting for a read on `file.pipeReader`.\r\n\r\nThis patch changes `(*Connection).ObjectCreate()`'s helper goroutine to close pipeReader when the request finishes in addition to closing `file.done`, and `(*ObjectCreateFile).Write()` is changed to use the `io.Pipe`'s signaling instead of `file.done`'s signaling. `file.done` is still neccessary to wait for completion of the request in `(*ObjectCreateFile).Close()`.","created_at":"2015-02-24T01:33:26Z","updated_at":"2015-02-27T10:43:56Z","closed_at":"2015-02-27T10:43:56Z","merged_at":"2015-02-27T10:43:56Z","merge_commit_sha":"db1ed3a868f264b5ecd0f0bf864576eea576656b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ncw/swift/pulls/35/commits","review_comments_url":"https://api.github.com/repos/ncw/swift/pulls/35/comments","review_comment_url":"https://api.github.com/repos/ncw/swift/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ncw/swift/issues/35/comments","statuses_url":"https://api.github.com/repos/ncw/swift/statuses/cdc25ed58b5ac8e046067ef97ad7e5d075078715","head":{"label":"encryptio:master","ref":"master","sha":"cdc25ed58b5ac8e046067ef97ad7e5d075078715","user":{"login":"encryptio","id":67937,"avatar_url":"https://avatars.githubusercontent.com/u/67937?v=3","gravatar_id":"","url":"https://api.github.com/users/encryptio","html_url":"https://github.com/encryptio","followers_url":"https://api.github.com/users/encryptio/followers","following_url":"https://api.github.com/users/encryptio/following{/other_user}","gists_url":"https://api.github.com/users/encryptio/gists{/gist_id}","starred_url":"https://api.github.com/users/encryptio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/encryptio/subscriptions","organizations_url":"https://api.github.com/users/encryptio/orgs","repos_url":"https://api.github.com/users/encryptio/repos","events_url":"https://api.github.com/users/encryptio/events{/privacy}","received_events_url":"https://api.github.com/users/encryptio/received_events","type":"User","site_admin":false},"repo":{"id":31239525,"name":"swift","full_name":"encryptio/swift","owner":{"login":"encryptio","id":67937,"avatar_url":"https://avatars.githubusercontent.com/u/67937?v=3","gravatar_id":"","url":"https://api.github.com/users/encryptio","html_url":"https://github.com/encryptio","followers_url":"https://api.github.com/users/encryptio/followers","following_url":"https://api.github.com/users/encryptio/following{/other_user}","gists_url":"https://api.github.com/users/encryptio/gists{/gist_id}","starred_url":"https://api.github.com/users/encryptio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/encryptio/subscriptions","organizations_url":"https://api.github.com/users/encryptio/orgs","repos_url":"https://api.github.com/users/encryptio/repos","events_url":"https://api.github.com/users/encryptio/events{/privacy}","received_events_url":"https://api.github.com/users/encryptio/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/encryptio/swift","description":"Go language interface to Swift / Openstack Object Storage / Rackspace cloud files (golang)","fork":true,"url":"https://api.github.com/repos/encryptio/swift","forks_url":"https://api.github.com/repos/encryptio/swift/forks","keys_url":"https://api.github.com/repos/encryptio/swift/keys{/key_id}","collaborators_url":"https://api.github.com/repos/encryptio/swift/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/encryptio/swift/teams","hooks_url":"https://api.github.com/repos/encryptio/swift/hooks","issue_events_url":"https://api.github.com/repos/encryptio/swift/issues/events{/number}","events_url":"https://api.github.com/repos/encryptio/swift/events","assignees_url":"https://api.github.com/repos/encryptio/swift/assignees{/user}","branches_url":"https://api.github.com/repos/encryptio/swift/branches{/branch}","tags_url":"https://api.github.com/repos/encryptio/swift/tags","blobs_url":"https://api.github.com/repos/encryptio/swift/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/encryptio/swift/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/encryptio/swift/git/refs{/sha}","trees_url":"https://api.github.com/repos/encryptio/swift/git/trees{/sha}","statuses_url":"https://api.github.com/repos/encryptio/swift/statuses/{sha}","languages_url":"https://api.github.com/repos/encryptio/swift/languages","stargazers_url":"https://api.github.com/repos/encryptio/swift/stargazers","contributors_url":"https://api.github.com/repos/encryptio/swift/contributors","subscribers_url":"https://api.github.com/repos/encryptio/swift/subscribers","subscription_url":"https://api.github.com/repos/encryptio/swift/subscription","commits_url":"https://api.github.com/repos/encryptio/swift/commits{/sha}","git_commits_url":"https://api.github.com/repos/encryptio/swift/git/commits{/sha}","comments_url":"https://api.github.com/repos/encryptio/swift/comments{/number}","issue_comment_url":"https://api.github.com/repos/encryptio/swift/issues/comments{/number}","contents_url":"https://api.github.com/repos/encryptio/swift/contents/{+path}","compare_url":"https://api.github.com/repos/encryptio/swift/compare/{base}...{head}","merges_url":"https://api.github.com/repos/encryptio/swift/merges","archive_url":"https://api.github.com/repos/encryptio/swift/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/encryptio/swift/downloads","issues_url":"https://api.github.com/repos/encryptio/swift/issues{/number}","pulls_url":"https://api.github.com/repos/encryptio/swift/pulls{/number}","milestones_url":"https://api.github.com/repos/encryptio/swift/milestones{/number}","notifications_url":"https://api.github.com/repos/encryptio/swift/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/encryptio/swift/labels{/name}","releases_url":"https://api.github.com/repos/encryptio/swift/releases{/id}","created_at":"2015-02-24T01:28:49Z","updated_at":"2015-02-24T01:29:35Z","pushed_at":"2015-02-24T01:29:35Z","git_url":"git://github.com/encryptio/swift.git","ssh_url":"git@github.com:encryptio/swift.git","clone_url":"https://github.com/encryptio/swift.git","svn_url":"https://github.com/encryptio/swift","homepage":null,"size":303,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"ncw:master","ref":"master","sha":"158da2171bff645b88cd1ac6a5422b643328b1f0","user":{"login":"ncw","id":536803,"avatar_url":"https://avatars.githubusercontent.com/u/536803?v=3","gravatar_id":"","url":"https://api.github.com/users/ncw","html_url":"https://github.com/ncw","followers_url":"https://api.github.com/users/ncw/followers","following_url":"https://api.github.com/users/ncw/following{/other_user}","gists_url":"https://api.github.com/users/ncw/gists{/gist_id}","starred_url":"https://api.github.com/users/ncw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ncw/subscriptions","organizations_url":"https://api.github.com/users/ncw/orgs","repos_url":"https://api.github.com/users/ncw/repos","events_url":"https://api.github.com/users/ncw/events{/privacy}","received_events_url":"https://api.github.com/users/ncw/received_events","type":"User","site_admin":false},"repo":{"id":6645769,"name":"swift","full_name":"ncw/swift","owner":{"login":"ncw","id":536803,"avatar_url":"https://avatars.githubusercontent.com/u/536803?v=3","gravatar_id":"","url":"https://api.github.com/users/ncw","html_url":"https://github.com/ncw","followers_url":"https://api.github.com/users/ncw/followers","following_url":"https://api.github.com/users/ncw/following{/other_user}","gists_url":"https://api.github.com/users/ncw/gists{/gist_id}","starred_url":"https://api.github.com/users/ncw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ncw/subscriptions","organizations_url":"https://api.github.com/users/ncw/orgs","repos_url":"https://api.github.com/users/ncw/repos","events_url":"https://api.github.com/users/ncw/events{/privacy}","received_events_url":"https://api.github.com/users/ncw/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ncw/swift","description":"Go language interface to Swift / Openstack Object Storage / Rackspace cloud files (golang)","fork":false,"url":"https://api.github.com/repos/ncw/swift","forks_url":"https://api.github.com/repos/ncw/swift/forks","keys_url":"https://api.github.com/repos/ncw/swift/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ncw/swift/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ncw/swift/teams","hooks_url":"https://api.github.com/repos/ncw/swift/hooks","issue_events_url":"https://api.github.com/repos/ncw/swift/issues/events{/number}","events_url":"https://api.github.com/repos/ncw/swift/events","assignees_url":"https://api.github.com/repos/ncw/swift/assignees{/user}","branches_url":"https://api.github.com/repos/ncw/swift/branches{/branch}","tags_url":"https://api.github.com/repos/ncw/swift/tags","blobs_url":"https://api.github.com/repos/ncw/swift/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ncw/swift/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ncw/swift/git/refs{/sha}","trees_url":"https://api.github.com/repos/ncw/swift/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ncw/swift/statuses/{sha}","languages_url":"https://api.github.com/repos/ncw/swift/languages","stargazers_url":"https://api.github.com/repos/ncw/swift/stargazers","contributors_url":"https://api.github.com/repos/ncw/swift/contributors","subscribers_url":"https://api.github.com/repos/ncw/swift/subscribers","subscription_url":"https://api.github.com/repos/ncw/swift/subscription","commits_url":"https://api.github.com/repos/ncw/swift/commits{/sha}","git_commits_url":"https://api.github.com/repos/ncw/swift/git/commits{/sha}","comments_url":"https://api.github.com/repos/ncw/swift/comments{/number}","issue_comment_url":"https://api.github.com/repos/ncw/swift/issues/comments{/number}","contents_url":"https://api.github.com/repos/ncw/swift/contents/{+path}","compare_url":"https://api.github.com/repos/ncw/swift/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ncw/swift/merges","archive_url":"https://api.github.com/repos/ncw/swift/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ncw/swift/downloads","issues_url":"https://api.github.com/repos/ncw/swift/issues{/number}","pulls_url":"https://api.github.com/repos/ncw/swift/pulls{/number}","milestones_url":"https://api.github.com/repos/ncw/swift/milestones{/number}","notifications_url":"https://api.github.com/repos/ncw/swift/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ncw/swift/labels{/name}","releases_url":"https://api.github.com/repos/ncw/swift/releases{/id}","created_at":"2012-11-11T23:01:03Z","updated_at":"2015-02-19T17:16:44Z","pushed_at":"2015-02-27T10:43:56Z","git_url":"git://github.com/ncw/swift.git","ssh_url":"git@github.com:ncw/swift.git","clone_url":"https://github.com/ncw/swift.git","svn_url":"https://github.com/ncw/swift","homepage":null,"size":670,"stargazers_count":76,"watchers_count":76,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":17,"mirror_url":null,"open_issues_count":2,"forks":17,"open_issues":2,"watchers":76,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ncw/swift/pulls/35"},"html":{"href":"https://github.com/ncw/swift/pull/35"},"issue":{"href":"https://api.github.com/repos/ncw/swift/issues/35"},"comments":{"href":"https://api.github.com/repos/ncw/swift/issues/35/comments"},"review_comments":{"href":"https://api.github.com/repos/ncw/swift/pulls/35/comments"},"review_comment":{"href":"https://api.github.com/repos/ncw/swift/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ncw/swift/pulls/35/commits"},"statuses":{"href":"https://api.github.com/repos/ncw/swift/statuses/cdc25ed58b5ac8e046067ef97ad7e5d075078715"}},"merged":true,"mergeable":null,"mergeable_state":"unknown","merged_by":{"login":"ncw","id":536803,"avatar_url":"https://avatars.githubusercontent.com/u/536803?v=3","gravatar_id":"","url":"https://api.github.com/users/ncw","html_url":"https://github.com/ncw","followers_url":"https://api.github.com/users/ncw/followers","following_url":"https://api.github.com/users/ncw/following{/other_user}","gists_url":"https://api.github.com/users/ncw/gists{/gist_id}","starred_url":"https://api.github.com/users/ncw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ncw/subscriptions","organizations_url":"https://api.github.com/users/ncw/orgs","repos_url":"https://api.github.com/users/ncw/repos","events_url":"https://api.github.com/users/ncw/events{/privacy}","received_events_url":"https://api.github.com/users/ncw/received_events","type":"User","site_admin":false},"comments":3,"review_comments":0,"commits":1,"additions":5,"deletions":6,"changed_files":1}}