python – 替换时的Couchbase KeyExistsError
发布时间:2020-12-20 13:08:19 所属栏目:Python 来源:网络整理
导读:当我尝试更新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.
当我尝试更新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$ 问题是我没有在我的代码中指定cas值,因此我没有在couchbase-python-client源代码中指定cas值 – 默认的cas值是zero,因此它应该忽略cas验证. couchbase服务器版本:3.0.1社区版(build-1444) couchbase-python-client版本:2.0.4 C库的版本: libcouchbase-dev:amd64 2.5.3-1 libcouchbase2-core:amd64 2.5.3-1 libcouchbase2-libevent:amd64 2.5.3-1 这是调用库的代码: def update(self,obj,cas=0): obj.validate() couch_doc = self.serializer.serialize_to_database(obj) self._connection.replace(couch_doc["id"],cas=cas) 解决方法
从您的代码看,它看起来像你指定cas:
self._connection.replace(couch_doc["id"],cas=cas) 你试过删除cas参数吗? (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |