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

Subdoc error handling appears to be incomplete

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 2.8.5
    • 2.8.4
    • library
    • None
    • 1

    Description

      It appears that not all subdoc errors are captured under https://github.com/couchbase/libcouchbase/blob/master/include/libcouchbase/error.h and https://github.com/couchbase/libcouchbase/blob/181c9eec56b3febb27e1abbed257d06f11a85ef6/src/handler.cc#L115.

      An example is:

      Status: Subdoc: Invalid combination for multi-path command (0x00cb)
      

      The error is thrown due to the fact that you are mutating more than 16 subdoc paths in a single command.

      When running under Python (I must confess I haven't created a libcouchbase program demonstrating the problem, but the errors are just passed through anyway), this is translated to the following error:

      couchbase.exceptions.LCB_0x3D (generated, catch: ): <Key='test', RC=0x3D[The server replied with an unrecognized status code. A newer version of this library may be able to decode it], Operational Error, Results=1, C Source=(src/multiresult.c,316)>
      

      An example python program to reproduce:

      from couchbase.bucket import Bucket
      import couchbase.subdocument as SD  # Use SD alias for brevity
       
      bkt = Bucket('couchbase://localhost/test', password='password')
      bkt.upsert('test', {})
      bkt.mutate_in('test', SD.upsert('a', '555-555-5555'), SD.upsert('b', '555-555-5555'),
      SD.upsert('c', '555-555-5555'), SD.upsert('d', '555-555-5555'), SD.upsert('e', '555-555-5555'),
      SD.upsert('f', '555-555-5555'), SD.upsert('g', '555-555-5555'), SD.upsert('h', '555-555-5555'),
      SD.upsert('i', '555-555-5555'), SD.upsert('j', '555-555-5555'), SD.upsert('k', '555-555-5555'),
      SD.upsert('l', '555-555-5555'), SD.upsert('m', '555-555-5555'), SD.upsert('n', '555-555-5555'),
      SD.upsert('o', '555-555-5555'), SD.upsert('p', '555-555-5555'), SD.upsert('q', '555-555-5555'),
      SD.upsert('r', '555-555-5555'), SD.upsert('s', '555-555-5555'), SD.upsert('t', '555-555-5555'))
      

      From a Python perspective this is a pain, as you can't catch the appropriate error.

      When running the same test under Java, this is translated to the correct error, providing a slightly more meaningful error to the user:

      Exception in thread "main" com.couchbase.client.core.CouchbaseException: SUBDOC_INVALID_COMBO
      	at com.couchbase.client.java.subdoc.SubdocHelper.commonSubdocErrors(SubdocHelper.java:95)
      	at com.couchbase.client.java.subdoc.AsyncMutateInBuilder$2.call(AsyncMutateInBuilder.java:764)
      	at com.couchbase.client.java.subdoc.AsyncMutateInBuilder$2.call(AsyncMutateInBuilder.java:722)
      	at rx.internal.operators.OnSubscribeMap$MapSubscriber.onNext(OnSubscribeMap.java:69)
      	at rx.internal.operators.OperatorMerge$MergeSubscriber.emitScalar(OperatorMerge.java:399)
      	at rx.internal.operators.OperatorMerge$MergeSubscriber.tryEmit(OperatorMerge.java:357)
      	at rx.internal.operators.OperatorMerge$InnerSubscriber.onNext(OperatorMerge.java:852)
      	at rx.internal.producers.SingleProducer.request(SingleProducer.java:65)
      	at rx.Subscriber.setProducer(Subscriber.java:211)
      	at rx.subjects.AsyncSubject.onCompleted(AsyncSubject.java:106)
      	at com.couchbase.client.core.endpoint.AbstractGenericHandler.completeResponse(AbstractGenericHandler.java:375)
      	at com.couchbase.client.core.endpoint.AbstractGenericHandler.access$000(AbstractGenericHandler.java:69)
      	at com.couchbase.client.core.endpoint.AbstractGenericHandler$1.call(AbstractGenericHandler.java:393)
      	at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
      	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      	at java.lang.Thread.run(Thread.java:745)
      

      I can see that we do capture the binary protocol error at https://github.com/couchbase/libcouchbase/blob/181c9eec56b3febb27e1abbed257d06f11a85ef6/include/memcached/protocol_binary.h#L208 but this never gets propagated anywhere.

      Attachments

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

        Activity

          People

            avsej Sergey Avseyev
            matt.carabine Matt Carabine (Inactive)
            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