删除后,Cassandra UPDATE无法正常工作

我在Cassandra中使用了宽行模式.我的表定义如下:

CREATE TABLE usertopics (
    key text,topic text,score counter,PRIMARY KEY (key,topic)
)

我正在插入条目使用:

UPDATE usertopics SET score = score + ? WHERE key=? AND topic=?

这样如果密钥不存在,它将插入,如果它存在,它将更新.

我正在删除使用的条目:

Delete form usertopics where key in ?

但删除后,当我再次尝试更新时,它没有更新.它没有给出任何错误,但它也没有反映在db中.

当我截断表格时,它再次完美插入.我正在使用Datastax java驱动程序访问Cassandra.有什么建议?

解决方法

来自cassandra文档 –

Counter removal is intrinsically limited. For instance,if you issue
very quickly the sequence “increment,remove,increment” it is
possible for the removal to be lost (if for some reason the remove
happens to be the last received messages). Hence,removal of counters
is provided for definitive removal only,that is when the deleted
counter is not increment afterwards. This holds for row deletion too:
if you delete a row of counters,incrementing any counter in that row
(that existed before the deletion) will result in an undetermined
behavior
. Note that if you need to reset a counter,one option (that
is unfortunately not concurrent safe) could be to read its value and
add -value.

删除后,不能/不应使用具有相同密钥的计数器.请使用以下链接获取更多信息 –

https://docs.datastax.com/en/cql/3.1/cql/cql_using/use_counter_t.html
https://wiki.apache.org/cassandra/Counters

相关文章

文章浏览阅读752次。关系型数据库关系型数据库是一个结构化的...
文章浏览阅读687次,点赞2次,收藏5次。商城系统中,抢购和秒...
文章浏览阅读1.4k次。MongoTemplate开发spring-data-mongodb...
文章浏览阅读887次,点赞10次,收藏19次。1.背景介绍1. 背景...
文章浏览阅读819次。MongoDB连接失败记录_edentialmechanisn...
文章浏览阅读470次。mongodb抽取数据到ES,使用ELK内部插件无...