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
- is duplicated by
-
MB-21915 4.5.1 / arrayAppend sometimes does not append value
- Closed