Uploaded image for project: 'Couchbase C client library libcouchbase'
  1. Couchbase C client library libcouchbase
  2. CCBC-1412

lcb_respstore_error_context() not populating scope & collection

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 3.1.4, 3.2.0
    • 3.1.3
    • None
    • None
    • 1

    Description

      Simple test Python program will seg fault when using CBS 7.0 and using actual scopes/collections (i.e. not default_collection()). Looking into the bindings (see gdb output below), it looks to happen because the lcb_respstore_error_context() method is not populating the scope and collection information correctly. I did find that if I build the Python client w/ LCB commit f8ccaa1c660c4967d47bda94398b2eeefc4e0607, I do not have this problem. Using CBS 7.0.0-5219 build.

      Please let me know if I am missing a change in the LCB API, or if further info should be provided.

      Python sample code.

      from couchbase.cluster import Cluster, ClusterOptions
      from couchbase.auth import PasswordAuthenticator
      import faulthandler
       
      cluster = Cluster('couchbase://localhost',
                        ClusterOptions(PasswordAuthenticator('Administrator', 'password')))
      bucket = cluster.bucket('default')
      scope = bucket.scope('test-scope')
      coll = scope.collection('test-collection')
       
      print(cluster.lcb_version())
      faulthandler.enable()
      coll.insert('test', {'info': 'this is a test'})
      
      

      gdb output when building w/ v3.1.3 (could also use LCB_TAG=0a2a74f5f900fd603bad7f96eeae2598dd8902a5 )

      Breakpoint 2, dur_chain2 (conn=0x7fd8f6758908, mres=0x7fd8f770c570, res=0x7fd8f6702588, cbtype=2, resp=0x7ffe36f69c70)
          at src/callbacks.c:749
      749         if ((mres->mropts & PYCBC_MRES_F_DURABILITY) == 0 || res->rc != LCB_SUCCESS) {
      (gdb) list
      744         }
      745
      746         /** For remove, we check quiet */
      747         MAYBE_PUSH_OPERR(mres, (pycbc_Result *)res, res->rc, is_delete ? 1 : 0);
      748
      749         if ((mres->mropts & PYCBC_MRES_F_DURABILITY) == 0 || res->rc != LCB_SUCCESS) {
      750             operation_completed_with_err_info(
      751                     conn, mres, cbtype, resp, (pycbc_Result *)res);
      752             CB_THR_BEGIN(conn);
      753             return;
      (gdb) p res->rc
      $1 = LCB_ERR_DOCUMENT_EXISTS
      (gdb) continue
      Continuing.
       
      Breakpoint 1, get_operation_err_info (respbase=0x7ffe36f69c70, cbtype=LCB_CALLBACK_STORE) at src/callbacks.c:245
      245                 break;
      (gdb) list
      240             case LCB_CALLBACK_GET:
      241                 rc = lcb_respget_error_context((const lcb_RESPGET*)respbase, &ctx);
      242                 break;
      243             case LCB_CALLBACK_STORE:
      244                 rc = lcb_respstore_error_context((const lcb_RESPSTORE*)respbase, &ctx);
      245                 break;
      246             case LCB_CALLBACK_UNLOCK:
      247                 rc = lcb_respunlock_error_context((const lcb_RESPUNLOCK*)respbase, &ctx);
      248                 break;
      249             case LCB_CALLBACK_TOUCH:
      (gdb) p ctx
      $2 = (const lcb_KEY_VALUE_ERROR_CONTEXT *) 0x7ffe36f69c70
      (gdb) p ctx->key
      $3 = 0x28d7923 "test{\"info\":\"this is a test\"}5235d04e88313378c82\",\"uri\":\"/pools/default/buckets/default?bucket_uuid=3b2ea9afe04d45235d04e88313378c82\",\"streamingUri\":\"/pools/default/bucketsStreaming/default?bucket_uui"...
      (gdb) p ctx->bucket
      $4 = 0x2712a80 "default"
      (gdb) p ctx->scope
      $5 = 0x28f87d0 "\300\030r\002"
      (gdb) p ctx->collection
      $6 = 0x28f87db "\002"
      (gdb) 
      

      gdb output when building w/ LCB_TAG=f8ccaa1c660c4967d47bda94398b2eeefc4e0607

      Breakpoint 2, dur_chain2 (conn=0x7f7362ceb908, mres=0x7f7363c9e570, res=0x7f7362c94588, cbtype=2, resp=
          0x7ffef87c4ef0) at src/callbacks.c:749
      749         if ((mres->mropts & PYCBC_MRES_F_DURABILITY) == 0 || res->rc != LCB_SUCCESS) {
      (gdb) list
      744         }
      745
      746         /** For remove, we check quiet */
      747         MAYBE_PUSH_OPERR(mres, (pycbc_Result *)res, res->rc, is_delete ? 1 : 0);
      748
      749         if ((mres->mropts & PYCBC_MRES_F_DURABILITY) == 0 || res->rc != LCB_SUCCESS) {
      750             operation_completed_with_err_info(
      751                     conn, mres, cbtype, resp, (pycbc_Result *)res);
      752             CB_THR_BEGIN(conn);
      753             return;
      (gdb) p res->rc
      $1 = LCB_ERR_DOCUMENT_EXISTS
      (gdb) continue
      Continuing.
       
      Breakpoint 1, get_operation_err_info (respbase=0x7ffef87c4ef0, cbtype=LCB_CALLBACK_STORE) at src/callbacks.c:245
      245                 break;
      (gdb) list
      240             case LCB_CALLBACK_GET:
      241                 rc = lcb_respget_error_context((const lcb_RESPGET*)respbase, &ctx);
      242                 break;
      243             case LCB_CALLBACK_STORE:
      244                 rc = lcb_respstore_error_context((const lcb_RESPSTORE*)respbase, &ctx);
      245                 break;
      246             case LCB_CALLBACK_UNLOCK:
      247                 rc = lcb_respunlock_error_context((const lcb_RESPUNLOCK*)respbase, &ctx);
      248                 break;
      249             case LCB_CALLBACK_TOUCH:
      (gdb) p ctx
      $2 = (const lcb_KEY_VALUE_ERROR_CONTEXT *) 0x7ffef87c4ef0
      (gdb) p ctx->key
      $3 = 0x26bc923 "test{\"info\":\"this is a test\"}5235d04e88313378c82\",\"uri\":\"/pools/default/buckets/default?bucket_uuid=3b2ea9afe04d45235d04e88313378c82\",\"streamingUri\":\"/pools/default/bucketsStreaming/default?bucket_uui"...
      (gdb) p ctx->bucket
      $4 = 0x2676a90 "default"
      (gdb) p ctx->scope
      $5 = 0x26dfee0 "test-scope.test-collection"
      (gdb) p ctx->collection
      $6 = 0x26dfeeb "test-collection"
      (gdb) 
      

      Attachments

        Issue Links

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

          Activity

            People

              brett19 Brett Lawson
              jared.casey Jared Casey
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty