Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass-thru view query is failing via admin api on view created with SG 1.1.1 #1493

Closed
tleyden opened this issue Jan 20, 2016 · 4 comments
Closed
Assignees
Labels
Milestone

Comments

@tleyden
Copy link
Contributor

tleyden commented Jan 20, 2016

Steps to repro:

  • Run sync gateway 1.1.1 (commit 2fff9eb)
  • Run code which adds views via admin port (4985)
  • Stop sync gateway 1.1.1, do not flush couchbase bucket
  • Run sync gateway 1.2.0-rc0 with this config
  • Run this code which will query a view on the admin port (4985) (and lazily add the view if it gets certain errors -- but the view should already be added)

Sync Gateway logs error:

2016-01-20T05:35:33.727Z HTTP:  #012: GET /deepstyle/_design/unprocessed_jobs/_view/unprocessed_jobs?stale=false  (ADMIN)
2016-01-20T05:35:33.727Z HTTP: JSON view "unprocessed_jobs"/"unprocessed_jobs" - opts map[stale:false]
2016/01/20 05:35:34 go-couchbase: call to ViewCustom("unprocessed_jobs", "unprocessed_jobs") in github.com/couchbase/sync_gateway/base.CouchbaseBucket.View.func1 took 556.351958ms
2016/01/20 05:35:34 http: panic serving [::1]:54096: interface conversion: interface is string, not []interface {}
goroutine 92 [running]:
net/http.(*conn).serve.func1(0xc8200b6b00, 0x7feccfe083c0, 0xc820022e40)
    /usr/local/go/src/net/http/server.go:1287 +0xb5
github.com/couchbase/sync_gateway/db.filterViewResult(0x1, 0xc820514ba0, 0x1, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    /opt/sync_gateway/src/github.com/couchbase/sync_gateway/db/design_doc.go:153 +0x416
github.com/couchbase/sync_gateway/db.(*Database).QueryDesignDoc(0xc820514660, 0xc8206f7cf7, 0x10, 0xc8206f7d0e, 0x10, 0xc8202e81b0, 0x3, 0x0, 0x0)
    /opt/sync_gateway/src/github.com/couchbase/sync_gateway/db/design_doc.go:126 +0x68c
github.com/couchbase/sync_gateway/rest.(*handler).handleView(0xc8206ab440, 0x0, 0x0)
    /opt/sync_gateway/src/github.com/couchbase/sync_gateway/rest/view_api.go:104 +0xb2f
github.com/couchbase/sync_gateway/rest.(*handler).invoke(0xc8206ab440, 0xfbf918, 0x0, 0x0)
    /opt/sync_gateway/src/github.com/couchbase/sync_gateway/rest/handler.go:201 +0x7b4
github.com/couchbase/sync_gateway/rest.makeHandler.func1(0x7feccfe1c778, 0xc8200b7ad0, 0xc820256b60)
    /opt/sync_gateway/src/github.com/couchbase/sync_gateway/rest/handler.go:90 +0x77
net/http.HandlerFunc.ServeHTTP(0xc82068dc60, 0x7feccfe1c778, 0xc8200b7ad0, 0xc820256b60)
    /usr/local/go/src/net/http/server.go:1422 +0x3a
github.com/gorilla/mux.(*Router).ServeHTTP(0xc820478230, 0x7feccfe1c778, 0xc8200b7ad0, 0xc820256b60)
    /opt/sync_gateway/src/github.com/gorilla/mux/mux.go:86 +0x2a6
github.com/couchbase/sync_gateway/rest.wrapRouter.func1(0x7feccfe1c778, 0xc8200b7ad0, 0xc820256b60)
    /opt/sync_gateway/src/github.com/couchbase/sync_gateway/rest/routing.go:299 +0x32d
net/http.HandlerFunc.ServeHTTP(0xc820634b60, 0x7feccfe1c778, 0xc8200b7ad0, 0xc820256b60)
    /usr/local/go/src/net/http/server.go:1422 +0x3a
net/http.serverHandler.ServeHTTP(0xc8206c3620, 0x7feccfe1c778, 0xc8200b7ad0, 0xc820256b60)
    /usr/local/go/src/net/http/server.go:1862 +0x19e
net/http.(*conn).serve(0xc8200b6b00)
    /usr/local/go/src/net/http/server.go:1361 +0xbee
created by net/http.(*Server).Serve
    /usr/local/go/src/net/http/server.go:1910 +0x3f6

I wonder if this is related to #862?

@tleyden
Copy link
Contributor Author

tleyden commented Jan 20, 2016

It looks like the problem is that when adding a view to Sync Gateway 1.1.1 via the REST api, it will create the view in couchbase server without the channel security view wrap. Later, when trying to run Sync Gateway 1.2 against that view it gives an unexpected response format.

Basically we don't have backwards compatibility for querying pre-1.2 views over the admin API.

@tleyden tleyden changed the title Pass-thru view query is failing Pass-thru view query is failing via admin api on view created with SG 1.1.1 Jan 20, 2016
@tleyden
Copy link
Contributor Author

tleyden commented Jan 21, 2016

I noticed what seems to be another change in behavior with SG 1.2.0-rc0 as compared with SG 1.1.1.

Previously when querying a non-existent view, SG would return a 404 error, now it's returning a 500 error:

Logs

@adamcfraser
Copy link
Collaborator

@tleyden Interesting - since the RetryLoop returns a custom error, the error isn't being converted to 404 by ErrorAsHTTPStatus. I could fix this for views specifically as part of this change, but I wonder if we actually want to change the RetryLoop handling to return the error from the last failed attempt, instead of a new generic error.

@adamcfraser
Copy link
Collaborator

Filed #1498 for the 500 error issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants