Uploaded image for project: 'Couchbase Python Client Library'
  1. Couchbase Python Client Library
  2. PYCBC-377

Cross-bucket N1QL queries fail even with "add_bucket_creds"

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.2.0
    • None
    • library
    • None
    • Ubuntu 16.04.1
      lcb 2.7.1

    Description

      The following query fails in the above mentioned environment:

      from couchbase.bucket import Bucket
      from couchbase.n1ql import N1QLQuery
       
      cb = Bucket("couchbase://172.23.100.55/bucket-1", password="password")
       
      cb.add_bucket_creds("bucket-1", "password")
      cb.add_bucket_creds("bucket-2", "password")
      cb.add_bucket_creds("bucket-3", "password")
       
       
      q = N1QLQuery("SELECT u.email AS email, COUNT(t.title) "
                    "FROM `bucket-2` t "
                    "INNER JOIN `bucket-3` c ON KEYS t.categories "
                    "LEFT OUTER JOIN `bucket-1` u ON KEYS t.owner "
                    "WHERE t.capped = $1 AND c.name = $2 "
                    "GROUP BY u.email", "d8576d", "n1ql-000000000001")
      q.adhoc = False
      q.consistency = 'not_bounded'
       
      cb.n1ql_query(q).execute()
      

      couchbase.exceptions.HTTPError: <RC=0x3B[HTTP Operation failed. Inspect status code for details], HTTP Request failed. Examine 'objextra' for full result, Results=1, C Source=(src/http.c,140), OBJ=ViewResult<rc=0x3B[HTTP Operation failed. Inspect status code for details], value={u'status': u'stopped', u'errors': [{u'msg': u'Authorization Failed Keyspace bucket-2', u'code': 10000}], u'results': [], u'metrics': {u'elapsedTime': u'6.651541ms', u'executionTime': u'6.579298ms', u'resultSize': 0, u'resultCount': 0, u'errorCount': 1}, u'requestID': u'4578d546-d2e0-4d6e-8ce7-575e8177ebe7', u'signature': {u'email': u'json', u'$1': u'number'}}, http_status=401>>
      

      Interestingly, the same code snippet works just fine on my laptop with lcb 2.6 and pycb 2.1.0.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          Huh, something is wrong with the text formatting in JIRA :/

          pavelpaulau Pavel Paulau (Inactive) added a comment - Huh, something is wrong with the text formatting in JIRA :/
          mnunberg Mark Nunberg (Inactive) added a comment - - edited

          You need to set the "cross_bucket" attribute on the query object itself. This feature was added in 2.2.0 I believe. See
          http://docs.couchbase.com/sdk-api/couchbase-python-client-2.2.0/api/n1ql.html#couchbase.n1ql.N1QLQuery.cross_bucket

          The reason is that a regular query is not by default a "Cross Bucket" query.

          mnunberg Mark Nunberg (Inactive) added a comment - - edited You need to set the "cross_bucket" attribute on the query object itself. This feature was added in 2.2.0 I believe. See http://docs.couchbase.com/sdk-api/couchbase-python-client-2.2.0/api/n1ql.html#couchbase.n1ql.N1QLQuery.cross_bucket The reason is that a regular query is not by default a "Cross Bucket" query.

          Yeah, cross_bucket helps.

          pavelpaulau Pavel Paulau (Inactive) added a comment - Yeah, cross_bucket helps.

          People

            mnunberg Mark Nunberg (Inactive)
            pavelpaulau Pavel Paulau (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty