{"action":"closed","number":2013,"pull_request":{"url":"https://api.github.com/repos/hyperledger/fabric/pulls/2013","id":75192892,"html_url":"https://github.com/hyperledger/fabric/pull/2013","diff_url":"https://github.com/hyperledger/fabric/pull/2013.diff","patch_url":"https://github.com/hyperledger/fabric/pull/2013.patch","issue_url":"https://api.github.com/repos/hyperledger/fabric/issues/2013","number":2013,"state":"closed","locked":false,"title":"Fixed GetRows() by moving defer into dependent goroutine","user":{"login":"bren3582","id":11986735,"avatar_url":"https://avatars.githubusercontent.com/u/11986735?v=3","gravatar_id":"","url":"https://api.github.com/users/bren3582","html_url":"https://github.com/bren3582","followers_url":"https://api.github.com/users/bren3582/followers","following_url":"https://api.github.com/users/bren3582/following{/other_user}","gists_url":"https://api.github.com/users/bren3582/gists{/gist_id}","starred_url":"https://api.github.com/users/bren3582/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bren3582/subscriptions","organizations_url":"https://api.github.com/users/bren3582/orgs","repos_url":"https://api.github.com/users/bren3582/repos","events_url":"https://api.github.com/users/bren3582/events{/privacy}","received_events_url":"https://api.github.com/users/bren3582/received_events","type":"User","site_admin":false},"body":"<!-- Provide a general summary of your changes in the Title above -->\r\n\r\n## Description\r\nWithin the `GetRows` function in `core/chaincode/shim/chaincode.go`, I have moved `defer iter.Close()` inside the goroutine which depends on `iter` for the reason explained below.\r\n\r\n## Motivation and Context\r\n<!-- Why is this change required? What problem does it solve? -->\r\n<!-- If it fixes an open issue, please link to the issue here. -->\r\nThe `GetRows` function uses a goroutine to get rows from a `StateRangeQueryIterator`. This iterator is used within the goroutine. Defer is used to wait until the function completes to clean up the iterator. However, the function can finish before the goroutine (in my case when there are a large number of rows requested), causing the iterator to be cleaned up before the goroutine is finished using it. This results in a chaincode error:\r\n```\r\n00:00:00 [shim] DEBU : [xxx]Sending RANGE_QUERY_STATE_NEXT\r\n00:00:00 [shim] DEBU : [xxx]Received message ERROR from shim\r\n00:00:00 [shim] DEBU : [xxx]Handling ChaincodeMessage of type: ERROR(state:ready)\r\nError starting chaincode: Error handling message: [xxx]Chaincode handler FSM cannot handle message (ERROR) with payload size (30) while in state: ready\r\n```\r\n\r\n## How Has This Been Tested?\r\nI tested this change against a chaincode project which requests a large number of rows from a table using the `GetRows` function. It solves the error shown above in a logical way. I created a separate [test to show the issue simply](https://play.golang.org/p/TNEh2gaB_m).\r\n\r\n## Checklist:\r\n<!-- To check a box, and an 'x': [x] -->\r\n<!-- To uncheck box, add a space: [ ] -->\r\n<!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->\r\n- [x] I have added a [Signed-off-by](https://github.com/hyperledger/fabric/blob/master/CONTRIBUTING.md#legal-stuff).\r\n- [x] I have either added documentation to cover my changes or this change requires no new documentation.\r\n- [x] I have either added unit tests to cover my changes or this change requires no new tests.\r\n- [x] I have run [golint](https://github.com/golang/lint) and have fixed valid warnings in code I have added or modified. This tool generates false positives so you may choose to ignore some warnings. The goal is clean, consistent, and readable code.\r\n\r\nThe continuous integration build process will run [make checks](https://github.com/hyperledger/fabric/blob/master/Makefile#L22) to confirm that tests pass and that code quality meets minimum standards. You may optionally run this locally as PRs will not be accepted until they pass.\r\n\r\nSigned-off-by: Brian Ensor <briancensor@gmail.com>","created_at":"2016-06-25T02:06:35Z","updated_at":"2016-07-06T18:01:17Z","closed_at":"2016-07-06T18:01:16Z","merged_at":null,"merge_commit_sha":"2d935a00c879d36da187312f71d838f1ff502cc5","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/hyperledger/fabric/pulls/2013/commits","review_comments_url":"https://api.github.com/repos/hyperledger/fabric/pulls/2013/comments","review_comment_url":"https://api.github.com/repos/hyperledger/fabric/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hyperledger/fabric/issues/2013/comments","statuses_url":"https://api.github.com/repos/hyperledger/fabric/statuses/6ec4e0bdd60eb0ee94cce1c66853fd5283ee47fa","head":{"label":"bren3582:fix-table-defers","ref":"fix-table-defers","sha":"6ec4e0bdd60eb0ee94cce1c66853fd5283ee47fa","user":{"login":"bren3582","id":11986735,"avatar_url":"https://avatars.githubusercontent.com/u/11986735?v=3","gravatar_id":"","url":"https://api.github.com/users/bren3582","html_url":"https://github.com/bren3582","followers_url":"https://api.github.com/users/bren3582/followers","following_url":"https://api.github.com/users/bren3582/following{/other_user}","gists_url":"https://api.github.com/users/bren3582/gists{/gist_id}","starred_url":"https://api.github.com/users/bren3582/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bren3582/subscriptions","organizations_url":"https://api.github.com/users/bren3582/orgs","repos_url":"https://api.github.com/users/bren3582/repos","events_url":"https://api.github.com/users/bren3582/events{/privacy}","received_events_url":"https://api.github.com/users/bren3582/received_events","type":"User","site_admin":false},"repo":{"id":60630053,"name":"fabric","full_name":"bren3582/fabric","owner":{"login":"bren3582","id":11986735,"avatar_url":"https://avatars.githubusercontent.com/u/11986735?v=3","gravatar_id":"","url":"https://api.github.com/users/bren3582","html_url":"https://github.com/bren3582","followers_url":"https://api.github.com/users/bren3582/followers","following_url":"https://api.github.com/users/bren3582/following{/other_user}","gists_url":"https://api.github.com/users/bren3582/gists{/gist_id}","starred_url":"https://api.github.com/users/bren3582/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bren3582/subscriptions","organizations_url":"https://api.github.com/users/bren3582/orgs","repos_url":"https://api.github.com/users/bren3582/repos","events_url":"https://api.github.com/users/bren3582/events{/privacy}","received_events_url":"https://api.github.com/users/bren3582/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bren3582/fabric","description":"Fabric is a blockchain project in Incubation proposed to the community and documented at https://goo.gl/RYQZ5N.  Information on what Incubation entails can be found in the Hyperledger Project Lifecycle document (https://goo.gl/4edNRc)","fork":true,"url":"https://api.github.com/repos/bren3582/fabric","forks_url":"https://api.github.com/repos/bren3582/fabric/forks","keys_url":"https://api.github.com/repos/bren3582/fabric/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bren3582/fabric/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bren3582/fabric/teams","hooks_url":"https://api.github.com/repos/bren3582/fabric/hooks","issue_events_url":"https://api.github.com/repos/bren3582/fabric/issues/events{/number}","events_url":"https://api.github.com/repos/bren3582/fabric/events","assignees_url":"https://api.github.com/repos/bren3582/fabric/assignees{/user}","branches_url":"https://api.github.com/repos/bren3582/fabric/branches{/branch}","tags_url":"https://api.github.com/repos/bren3582/fabric/tags","blobs_url":"https://api.github.com/repos/bren3582/fabric/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bren3582/fabric/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bren3582/fabric/git/refs{/sha}","trees_url":"https://api.github.com/repos/bren3582/fabric/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bren3582/fabric/statuses/{sha}","languages_url":"https://api.github.com/repos/bren3582/fabric/languages","stargazers_url":"https://api.github.com/repos/bren3582/fabric/stargazers","contributors_url":"https://api.github.com/repos/bren3582/fabric/contributors","subscribers_url":"https://api.github.com/repos/bren3582/fabric/subscribers","subscription_url":"https://api.github.com/repos/bren3582/fabric/subscription","commits_url":"https://api.github.com/repos/bren3582/fabric/commits{/sha}","git_commits_url":"https://api.github.com/repos/bren3582/fabric/git/commits{/sha}","comments_url":"https://api.github.com/repos/bren3582/fabric/comments{/number}","issue_comment_url":"https://api.github.com/repos/bren3582/fabric/issues/comments{/number}","contents_url":"https://api.github.com/repos/bren3582/fabric/contents/{+path}","compare_url":"https://api.github.com/repos/bren3582/fabric/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bren3582/fabric/merges","archive_url":"https://api.github.com/repos/bren3582/fabric/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bren3582/fabric/downloads","issues_url":"https://api.github.com/repos/bren3582/fabric/issues{/number}","pulls_url":"https://api.github.com/repos/bren3582/fabric/pulls{/number}","milestones_url":"https://api.github.com/repos/bren3582/fabric/milestones{/number}","notifications_url":"https://api.github.com/repos/bren3582/fabric/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bren3582/fabric/labels{/name}","releases_url":"https://api.github.com/repos/bren3582/fabric/releases{/id}","deployments_url":"https://api.github.com/repos/bren3582/fabric/deployments","created_at":"2016-06-07T16:44:48Z","updated_at":"2016-06-07T16:44:50Z","pushed_at":"2016-07-06T15:44:31Z","git_url":"git://github.com/bren3582/fabric.git","ssh_url":"git@github.com:bren3582/fabric.git","clone_url":"https://github.com/bren3582/fabric.git","svn_url":"https://github.com/bren3582/fabric","homepage":"","size":44885,"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":"hyperledger:master","ref":"master","sha":"2aeddd6929d7108bda6a498d1d64e771177c5270","user":{"login":"hyperledger","id":7657900,"avatar_url":"https://avatars.githubusercontent.com/u/7657900?v=3","gravatar_id":"","url":"https://api.github.com/users/hyperledger","html_url":"https://github.com/hyperledger","followers_url":"https://api.github.com/users/hyperledger/followers","following_url":"https://api.github.com/users/hyperledger/following{/other_user}","gists_url":"https://api.github.com/users/hyperledger/gists{/gist_id}","starred_url":"https://api.github.com/users/hyperledger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hyperledger/subscriptions","organizations_url":"https://api.github.com/users/hyperledger/orgs","repos_url":"https://api.github.com/users/hyperledger/repos","events_url":"https://api.github.com/users/hyperledger/events{/privacy}","received_events_url":"https://api.github.com/users/hyperledger/received_events","type":"Organization","site_admin":false},"repo":{"id":42975662,"name":"fabric","full_name":"hyperledger/fabric","owner":{"login":"hyperledger","id":7657900,"avatar_url":"https://avatars.githubusercontent.com/u/7657900?v=3","gravatar_id":"","url":"https://api.github.com/users/hyperledger","html_url":"https://github.com/hyperledger","followers_url":"https://api.github.com/users/hyperledger/followers","following_url":"https://api.github.com/users/hyperledger/following{/other_user}","gists_url":"https://api.github.com/users/hyperledger/gists{/gist_id}","starred_url":"https://api.github.com/users/hyperledger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hyperledger/subscriptions","organizations_url":"https://api.github.com/users/hyperledger/orgs","repos_url":"https://api.github.com/users/hyperledger/repos","events_url":"https://api.github.com/users/hyperledger/events{/privacy}","received_events_url":"https://api.github.com/users/hyperledger/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hyperledger/fabric","description":"Fabric is a blockchain project in Incubation proposed to the community and documented at https://goo.gl/RYQZ5N.  Information on what Incubation entails can be found in the Hyperledger Project Lifecycle document (https://goo.gl/4edNRc)","fork":false,"url":"https://api.github.com/repos/hyperledger/fabric","forks_url":"https://api.github.com/repos/hyperledger/fabric/forks","keys_url":"https://api.github.com/repos/hyperledger/fabric/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hyperledger/fabric/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hyperledger/fabric/teams","hooks_url":"https://api.github.com/repos/hyperledger/fabric/hooks","issue_events_url":"https://api.github.com/repos/hyperledger/fabric/issues/events{/number}","events_url":"https://api.github.com/repos/hyperledger/fabric/events","assignees_url":"https://api.github.com/repos/hyperledger/fabric/assignees{/user}","branches_url":"https://api.github.com/repos/hyperledger/fabric/branches{/branch}","tags_url":"https://api.github.com/repos/hyperledger/fabric/tags","blobs_url":"https://api.github.com/repos/hyperledger/fabric/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hyperledger/fabric/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hyperledger/fabric/git/refs{/sha}","trees_url":"https://api.github.com/repos/hyperledger/fabric/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hyperledger/fabric/statuses/{sha}","languages_url":"https://api.github.com/repos/hyperledger/fabric/languages","stargazers_url":"https://api.github.com/repos/hyperledger/fabric/stargazers","contributors_url":"https://api.github.com/repos/hyperledger/fabric/contributors","subscribers_url":"https://api.github.com/repos/hyperledger/fabric/subscribers","subscription_url":"https://api.github.com/repos/hyperledger/fabric/subscription","commits_url":"https://api.github.com/repos/hyperledger/fabric/commits{/sha}","git_commits_url":"https://api.github.com/repos/hyperledger/fabric/git/commits{/sha}","comments_url":"https://api.github.com/repos/hyperledger/fabric/comments{/number}","issue_comment_url":"https://api.github.com/repos/hyperledger/fabric/issues/comments{/number}","contents_url":"https://api.github.com/repos/hyperledger/fabric/contents/{+path}","compare_url":"https://api.github.com/repos/hyperledger/fabric/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hyperledger/fabric/merges","archive_url":"https://api.github.com/repos/hyperledger/fabric/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hyperledger/fabric/downloads","issues_url":"https://api.github.com/repos/hyperledger/fabric/issues{/number}","pulls_url":"https://api.github.com/repos/hyperledger/fabric/pulls{/number}","milestones_url":"https://api.github.com/repos/hyperledger/fabric/milestones{/number}","notifications_url":"https://api.github.com/repos/hyperledger/fabric/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hyperledger/fabric/labels{/name}","releases_url":"https://api.github.com/repos/hyperledger/fabric/releases{/id}","deployments_url":"https://api.github.com/repos/hyperledger/fabric/deployments","created_at":"2015-09-23T03:17:14Z","updated_at":"2016-07-06T15:49:06Z","pushed_at":"2016-07-06T17:46:38Z","git_url":"git://github.com/hyperledger/fabric.git","ssh_url":"git@github.com:hyperledger/fabric.git","clone_url":"https://github.com/hyperledger/fabric.git","svn_url":"https://github.com/hyperledger/fabric","homepage":"","size":79413,"stargazers_count":880,"watchers_count":880,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":826,"mirror_url":null,"open_issues_count":381,"forks":826,"open_issues":381,"watchers":880,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hyperledger/fabric/pulls/2013"},"html":{"href":"https://github.com/hyperledger/fabric/pull/2013"},"issue":{"href":"https://api.github.com/repos/hyperledger/fabric/issues/2013"},"comments":{"href":"https://api.github.com/repos/hyperledger/fabric/issues/2013/comments"},"review_comments":{"href":"https://api.github.com/repos/hyperledger/fabric/pulls/2013/comments"},"review_comment":{"href":"https://api.github.com/repos/hyperledger/fabric/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hyperledger/fabric/pulls/2013/commits"},"statuses":{"href":"https://api.github.com/repos/hyperledger/fabric/statuses/6ec4e0bdd60eb0ee94cce1c66853fd5283ee47fa"}},"merged":false,"mergeable":true,"mergeable_state":"unstable","merged_by":null,"comments":19,"review_comments":7,"commits":1,"additions":1,"deletions":1,"changed_files":1}}
{"actor":{"display_login":"bren3582"}}