Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-21597

Subdoc atomic/concurrency broken

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: master, 4.5.1
    • Fix Version/s: 4.6.0
    • Component/s: memcached
    • Labels:
      None

      Description

      Subdocument concurrency is broken - it seems we overwrite previous mutations without regard for actually checking the CAS. The example below will spit out a different number for each run, indicating that some of the mutations are indeed being swallowed.

      #!/usr/bin/env python
      from threading import Thread
       
      from couchbase.bucket import Bucket
      import couchbase.subdocument as SD
       
       
      DOCID = 'subdoc_doc_id'
      CONNSTR = 'couchbase://localhost:12000'
      ITERATIONS = 200
      THREADS = 20
       
      main_bucket = Bucket(CONNSTR)
      main_bucket.upsert(DOCID, {'recs':[]})
       
      thrs = []
       
      class Runner(Thread):
          def run(self, *args, **kw):
              cb = Bucket(CONNSTR)
              for x in range(ITERATIONS):
                  cb.mutate_in(DOCID, SD.array_append('recs', 1))
       
      thrs = [Runner() for x in range(THREADS)]
      [t.start() for t in thrs]
      [t.join() for t in thrs]
       
      obj = main_bucket.get(DOCID)
      print 'Object has {} items'.format(len(obj.value['recs']))
      

        Attachments

          Issue Links

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

            Activity

            Hide
            ericcooper Eric Cooper (Inactive) added a comment -

            Looking at the existing subdoc test cases I see we do arrayprepend_in, addunique_in, etc but not mutate_in. Do you know if this issue unique to mutate_in?

            Show
            ericcooper Eric Cooper (Inactive) added a comment - Looking at the existing subdoc test cases I see we do arrayprepend_in, addunique_in, etc but not mutate_in. Do you know if this issue unique to mutate_in?
            Hide
            mnunberg Mark Nunberg (Inactive) added a comment -

            There shouldn't be a difference between them.

            Show
            mnunberg Mark Nunberg (Inactive) added a comment - There shouldn't be a difference between them.
            Hide
            pvarley Patrick Varley added a comment -

            FYI, this also affects subdoc operations using CAS.

            Show
            pvarley Patrick Varley added a comment - FYI, this also affects subdoc operations using CAS.
            Hide
            build-team Couchbase Build Team added a comment -

            Build 4.6.0-3469 contains memcached commit 098c351ef3877bd3bebc92feebc9d368bde79759 with commit message:
            MB-21597: Use OPERATION_CAS rather than OPERATION_REPLACE
            https://github.com/couchbase/memcached/commit/098c351ef3877bd3bebc92feebc9d368bde79759

            Show
            build-team Couchbase Build Team added a comment - Build 4.6.0-3469 contains memcached commit 098c351ef3877bd3bebc92feebc9d368bde79759 with commit message: MB-21597 : Use OPERATION_CAS rather than OPERATION_REPLACE https://github.com/couchbase/memcached/commit/098c351ef3877bd3bebc92feebc9d368bde79759
            Hide
            build-team Couchbase Build Team added a comment -

            Build 4.5.1-2848 contains memcached commit aa8c06717967363ad76ad1cc1288f33c65fbee31 with commit message:
            MB-21597: Use OPERATION_CAS rather than OPERATION_REPLACE
            https://github.com/couchbase/memcached/commit/aa8c06717967363ad76ad1cc1288f33c65fbee31

            Show
            build-team Couchbase Build Team added a comment - Build 4.5.1-2848 contains memcached commit aa8c06717967363ad76ad1cc1288f33c65fbee31 with commit message: MB-21597 : Use OPERATION_CAS rather than OPERATION_REPLACE https://github.com/couchbase/memcached/commit/aa8c06717967363ad76ad1cc1288f33c65fbee31
            Hide
            build-team Couchbase Build Team added a comment -

            Build 4.7.0-1312 contains memcached commit 098c351ef3877bd3bebc92feebc9d368bde79759 with commit message:
            MB-21597: Use OPERATION_CAS rather than OPERATION_REPLACE
            https://github.com/couchbase/memcached/commit/098c351ef3877bd3bebc92feebc9d368bde79759

            Show
            build-team Couchbase Build Team added a comment - Build 4.7.0-1312 contains memcached commit 098c351ef3877bd3bebc92feebc9d368bde79759 with commit message: MB-21597 : Use OPERATION_CAS rather than OPERATION_REPLACE https://github.com/couchbase/memcached/commit/098c351ef3877bd3bebc92feebc9d368bde79759
            Hide
            ericcooper Eric Cooper (Inactive) added a comment -

            I created CBQE-3709 to create an automated test for this scenario.

            Show
            ericcooper Eric Cooper (Inactive) added a comment - I created CBQE-3709 to create an automated test for this scenario.
            Hide
            pvarley Patrick Varley added a comment -

            I believe CBQE-3721 has the fix for the test suit.

            Show
            pvarley Patrick Varley added a comment - I believe CBQE-3721 has the fix for the test suit.

              People

              • Assignee:
                mnunberg Mark Nunberg (Inactive)
                Reporter:
                mnunberg Mark Nunberg (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                10 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes

                    PagerDuty

                    Error rendering 'com.pagerduty.jira-server-plugin:PagerDuty'. Please contact your Jira administrators.