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

Subdoc atomic/concurrency broken

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Critical
    • 4.6.0
    • master, 4.5.1
    • memcached
    • 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

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved:

                PagerDuty