【问题标题】:Couchbase KeyExistsError on replaceCouchbase KeyExistsError 替换
【发布时间】:2016-01-30 23:29:21
【问题描述】:

我在尝试更新 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 值是 @ 987654321@ 所以它应该忽略 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"], couch_doc, persist_to=1, cas=cas)

【问题讨论】:

    标签: python couchbase


    【解决方案1】:

    从您的代码看来,您确实在指定 cas:

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

    您是否尝试过删除cas 参数?

    【讨论】:

    猜你喜欢
    • 2023-04-05
    • 2020-10-09
    • 2015-06-19
    • 1970-01-01
    • 2012-08-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多