{"action":"created","issue":{"url":"https://api.github.com/repos/couchbase/sync_gateway/issues/676","labels_url":"https://api.github.com/repos/couchbase/sync_gateway/issues/676/labels{/name}","comments_url":"https://api.github.com/repos/couchbase/sync_gateway/issues/676/comments","events_url":"https://api.github.com/repos/couchbase/sync_gateway/issues/676/events","html_url":"https://github.com/couchbase/sync_gateway/issues/676","id":58685436,"number":676,"title":"Query view with include_docs=true returns no rows (or Internal Server Error)","user":{"login":"stemail23","id":511098,"avatar_url":"https://avatars.githubusercontent.com/u/511098?v=3","gravatar_id":"","url":"https://api.github.com/users/stemail23","html_url":"https://github.com/stemail23","followers_url":"https://api.github.com/users/stemail23/followers","following_url":"https://api.github.com/users/stemail23/following{/other_user}","gists_url":"https://api.github.com/users/stemail23/gists{/gist_id}","starred_url":"https://api.github.com/users/stemail23/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stemail23/subscriptions","organizations_url":"https://api.github.com/users/stemail23/orgs","repos_url":"https://api.github.com/users/stemail23/repos","events_url":"https://api.github.com/users/stemail23/events{/privacy}","received_events_url":"https://api.github.com/users/stemail23/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-02-24T02:39:16Z","updated_at":"2015-02-27T07:12:16Z","closed_at":null,"body":"Couchbase Server = 3.0.2-1603 Enterprise Edition (build-1603)\r\nSync_Gateway = Couchbase Sync Gateway/master(da04959)\r\n\r\nWhen attempting to query sync_gateway admin channel views with `include_docs=true`, no rows are returned:\r\n\r\n`curl \"http://user:password@localhost:4985/unit_tests/_design/testDoc/_view/testView?key=%22test_data%22&stale=false&include_docs=false\"`\r\nreturns\r\n`{\"total_rows\":3,\"rows\":[{\"id\":\"test_data\",\"key\":\"test_data\",\"value\":null}]}`\r\n\r\n`curl \"http://user:password@localhost:4985/unit_tests/_design/testDoc/_view/testView?key=%22test_data%22&stale=false&include_docs=true\"`\r\nreturns\r\n`{\"total_rows\":0,\"rows\":null}`\r\n\r\nThis is with the current git master branch code. Attempting the same with the release version download (Couchbase Sync Gateway/1.0.3(81; fa9a6e7)) results in:\r\n\r\n`curl \"http://user:password@localhost:4985/unit_tests/_design/testDoc/_view/testView?key=%22test_data%22&stale=false&include_docs=true\"`\r\nreturns\r\n`{\"error\":\"Internal Server Error\",\"reason\":\"Internal error: invalid byte in chunk length\"}`\r\n\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/couchbase/sync_gateway/issues/comments/76349043","html_url":"https://github.com/couchbase/sync_gateway/issues/676#issuecomment-76349043","issue_url":"https://api.github.com/repos/couchbase/sync_gateway/issues/676","id":76349043,"user":{"login":"ingenthr","id":81302,"avatar_url":"https://avatars.githubusercontent.com/u/81302?v=3","gravatar_id":"","url":"https://api.github.com/users/ingenthr","html_url":"https://github.com/ingenthr","followers_url":"https://api.github.com/users/ingenthr/followers","following_url":"https://api.github.com/users/ingenthr/following{/other_user}","gists_url":"https://api.github.com/users/ingenthr/gists{/gist_id}","starred_url":"https://api.github.com/users/ingenthr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ingenthr/subscriptions","organizations_url":"https://api.github.com/users/ingenthr/orgs","repos_url":"https://api.github.com/users/ingenthr/repos","events_url":"https://api.github.com/users/ingenthr/events{/privacy}","received_events_url":"https://api.github.com/users/ingenthr/received_events","type":"User","site_admin":false},"created_at":"2015-02-27T07:12:15Z","updated_at":"2015-02-27T07:12:15Z","body":"I don't work on Sync Gateway, but I may be able to help.  \r\n\r\nWhen Couchbase Server 2.0 was planned out, the team at the time intentionally deprecated support for include_docs.  It was documented as not supported, though it was still there and did work at a significant performance penalty.  In the SDKs, Couchbase added support for a \"logical\" include_docs, which did a KV fetch for the document asynchronously/in-parallel when passing the view results back to the application calling it's API.\r\n\r\ninclude_docs is likely still there through 2.5, but it was removed in 3.0 as @adamcfraser found.\r\n\r\nOne workaround would be to move to Couchbase 2.5.  The disadvantage here is that the views are significantly slower in 2.5... slower to update in particular.  It may also have some poor resource usage characteristics.\r\n\r\nThe best approach is probably for Sync Gateway to implement the same logical include_docs when it proxies this request.  Do note, however, there is a slight semantic difference with respect to CouchDB as a document may differ from what's in the view or may not exist at all, since the doc is not being fetched as the specific version being referred to in the view, but rather the current state as known in memory.  The semantics are different w.r.t. CouchDB in some other ways too, as the view execution on a distributed system can vary since the time and order in which things are processed will be relative to the the place executing the query and the state of the systems it's querying before the merge.\r\n\r\nThat may be fine for your app though @stemail23, in which case you'd just need SG to add the logical fetch to support what you need."}}