Uploaded image for project: 'Couchbase Java Client'
  1. Couchbase Java Client
  2. JCBC-150

"Failed to access the view" error when querying a view with reduce

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 1.1-dp4
    • Fix Version/s: None
    • Component/s: Core
    • Security Level: Public
    • Labels:
      None

      Description

      Attempting to make a call to CouchbaseClient.query(view, query) with a view that has a reduce (even just "_count") results in the following exception when results are returned:

      java.lang.RuntimeException: Failed to access the view
      at com.couchbase.client.CouchbaseClient.query(CouchbaseClient.java:634)

      Worth noting:

      • If the query returns no results (ViewResponse.size() returns 0), you do not get the exception...
      • If the reduce method is removed from the view, everything works fine. However, using query.setReduce(false) does not work.
      No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

        Hide
        daschl Michael Nitschinger added a comment -

        fixed and pushed to master; will be available in dp5/beta.

        Show
        daschl Michael Nitschinger added a comment - fixed and pushed to master; will be available in dp5/beta.
        Hide
        daschl Michael Nitschinger added a comment - - edited

        After more investigation, this is really a shortcoming and should be handled in this changeset:

        http://review.couchbase.org/#/c/22710/

        It makes sure that reduce = true when nothing is set and the view contains a reduce function. The exception was misleading because it covered a JSON parsing bug underneath.

        Show
        daschl Michael Nitschinger added a comment - - edited After more investigation, this is really a shortcoming and should be handled in this changeset: http://review.couchbase.org/#/c/22710/ It makes sure that reduce = true when nothing is set and the view contains a reduce function. The exception was misleading because it covered a JSON parsing bug underneath.
        Hide
        daschl Michael Nitschinger added a comment -

        Please make sure to use setReduce(true) and .setReduce(false) explicitely on a view with a reduce function right now.

        The following code works with setReduce(true) and false, but will throw the exception you mentioned when setReduce is not used at all:

        query = new Query();
        //query.setReduce(false);
        view = client.getView(DESIGN_DOC_W_REDUCE, VIEW_NAME_W_REDUCE);
        reduce = client.query(view, query);
        itr = reduce.iterator();
        while(itr.hasNext())

        { ViewRow row = itr.next(); System.out.println(row.getKey()); }
        Show
        daschl Michael Nitschinger added a comment - Please make sure to use setReduce(true) and .setReduce(false) explicitely on a view with a reduce function right now. The following code works with setReduce(true) and false, but will throw the exception you mentioned when setReduce is not used at all: query = new Query(); //query.setReduce(false); view = client.getView(DESIGN_DOC_W_REDUCE, VIEW_NAME_W_REDUCE); reduce = client.query(view, query); itr = reduce.iterator(); while(itr.hasNext()) { ViewRow row = itr.next(); System.out.println(row.getKey()); }
        Hide
        daschl Michael Nitschinger added a comment -

        Hi Chris,

        thanks for the report. I'll investigate and let you know!

        Thanks,
        Michael

        Show
        daschl Michael Nitschinger added a comment - Hi Chris, thanks for the report. I'll investigate and let you know! Thanks, Michael

          People

          • Assignee:
            daschl Michael Nitschinger
            Reporter:
            ctash_jt Chris Tashjian
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Gerrit Reviews

              There are no open Gerrit changes