Couchbase KeyExistsError to replace

I get the following error when I try to update an object in couchbase:

 File "./*/couchbase_repository.py", line 55, in update self.repository.update(group)
self._connection.replace(couch_doc["id"], couch_doc, persist_to=1, cas=cas)
File "/opt/*/virtualenv/lib/python2.7/site-packages/couchbase/bucket.py", line 377, in replace
persist_to=persist_to, replicate_to=replicate_to)
_KeyExistsError_0xC (generated, catch KeyExistsError): <Key=u'*', RC=0xC[The key already exists in the server. If you have supplied a CAS then the key exists with a CAS value different than speci$

The problem is that I do not specify the cas value in my code and, accordingly, the couchbase-python-client source code - the default value of cas is zero , so it should ignore the cas check.

couchbase server version: 3.0.1 Community Edition (build-1444)

couchbase-python-client version: 2.0.4

C Library Versions:

libcouchbase-dev: amd64 2.5.3-1

libcouchbase2-core: amd64 2.5.3-1

libcouchbase2-libevent: amd64 2.5.3-1

This is the code that calls the library:

    def update(self, obj, cas=0):
        obj.validate()
        couch_doc = self.serializer.serialize_to_database(obj)
        self._connection.replace(couch_doc["id"], couch_doc, persist_to=1, cas=cas)
+4
source share
1 answer

, cas:

self._connection.replace(couch_doc["id"], couch_doc, persist_to=1, cas=cas)

cas?

0

Source: https://habr.com/ru/post/1613847/


All Articles