Cassandra更新无效地与几个节点

编程入门 行业动态 更新时间:2024-10-24 23:30:17
本文介绍了Cassandra更新无效地与几个节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有以下情况。

有一个CQL表(Cassandra 2.0.12)

CREATE TABLE article( version timeuuid, id timeuuid, active boolean, contentbody text, contentformat text, createdat text, entitytype text, externalsources list< text>, geolat double, geolong double, lastcomments list< text> ;, lastmodifiedat text, lstmodbyuserid text, lstmodbyusername text, previewimage text, publishedatarticle text static, publishedatver text, status text, subcategory文本,字幕文本,标题文本,用户标识文本静态,用户名文本静态, PRIMARY KEY((版本),id)) WITH bloom_filter_fp_chance = 0.010000 AND caching ='KEYS_ONLY'AND comment =''AND dclocal_read_repair_chance = 0.100000 AND gc_grace_seconds = 864000 AND index_interval = 128 AND read_repair_chance = 0.000000 AND replicate_on_write ='true'AND populate_io_cache_on_flush ='false'AND default_time_to_live = 0 AND speculative_retry = '99 .0PERCENTILE'AND memtable_flush_period_in_ms = 0 AND compaction = {'class':'SizeTieredCompactionStrategy'} AND compression = {'sstable_compression':'LZ4Compressor'};

并使用datastax-java-driver(cassandra-driver-core 2.1.1) / p>

当集群包含3个节点数据更新时,如

title ='updated title2',subtitle = null,status ='draft',subCategory ='{id:a6b68330-2ef5-4267-98c5-cd793edbb1a8,name:sub cat name,color :blue,parentCategory:{id:prim_cat_id,name:prim cat name,color:blue}}',contentBody ='someOtherBody',contentFormat ='someOtherFormat' ,geoLat = 138782.34,geoLong = 138782.34,lastModifiedAt ='2015-03-02 11:14:57',publishedAtArticle = null,publishedAtVer = null,lstModByUserId ='e264fb2c-2485-488a-965f-765d139be9ea',lstModByUsername ='reg1 user',externalSources = [],previewImage ='{width:1,height:2,duration:32,original:orig string,thumbs:{prefix: str,ext:jpg,sizes:[size1,size2]}}'WHERE version = 2480d891-c0cd-11e4-a691-df79ef55172c AND id = 2480d890-c0cd-11e4-a691- df79ef55172c;

在大约一半的情况下无效(在Cassandra日志中没有错误,没有可疑在跟踪,没有失败的答案或异常,我可以看到,它没有成功只是通过SELECT)。在一个节点的群集的情况下,它总是工作。

你能帮助我在调查的一些方向吗?

解决方案

由于你提到你的节点时间不同步,你可能有一个罕见但仍然可能的条件。 / p>

如果节点之间的时间不同步,则在更新/插入过程中可能会导致一些不可预测的结果。

通常在写入时,具有最新时间戳的一个获胜。如果你的一个节点有时间后面,那么当它成为一个协调器时,它用它的时间戳戳记所有的记录,因此决定这个更新太旧,因为已经有其他更新与更新的时间戳(从节点准确时间)。因此丢弃更新。

I have following situation.

There is a CQL table (Cassandra 2.0.12)

CREATE TABLE article ( version timeuuid, id timeuuid, active boolean, contentbody text, contentformat text, createdat text, entitytype text, externalsources list<text>, geolat double, geolong double, lastcomments list<text>, lastmodifiedat text, lstmodbyuserid text, lstmodbyusername text, previewimage text, publishedatarticle text static, publishedatver text, status text, subcategory text, subtitle text, title text, userid text static, username text static, PRIMARY KEY ((version), id) ) WITH bloom_filter_fp_chance=0.010000 AND caching='KEYS_ONLY' AND comment='' AND dclocal_read_repair_chance=0.100000 AND gc_grace_seconds=864000 AND index_interval=128 AND read_repair_chance=0.000000 AND replicate_on_write='true' AND populate_io_cache_on_flush='false' AND default_time_to_live=0 AND speculative_retry='99.0PERCENTILE' AND memtable_flush_period_in_ms=0 AND compaction={'class': 'SizeTieredCompactionStrategy'} AND compression={'sstable_compression': 'LZ4Compressor'};

and work with it with datastax-java-driver (cassandra-driver-core 2.1.1)

When cluster contains 3 nodes data update, like

UPDATE article SET title='updated title2',subtitle=null,status='draft',subCategory='{"id":"a6b68330-2ef5-4267-98c5-cd793edbb1a8","name":"sub cat name","color":"blue","parentCategory":{"id":"prim_cat_id","name":"prim cat name","color":"blue"}}',contentBody='someOtherBody',contentFormat='someOtherFormat',geoLat=138782.34,geoLong=138782.34,lastModifiedAt='2015-03-02 11:14:57',publishedAtArticle=null,publishedAtVer=null,lstModByUserId='e264fb2c-2485-488a-965f-765d139be9ea',lstModByUsername='reg1 user',externalSources=[],previewImage='{"width":1,"height":2,"duration":32,"original":"orig string","thumbs":{"prefix":"prefix str","ext":"jpg","sizes":["size1","size2"]}}' WHERE version=2480d891-c0cd-11e4-a691-df79ef55172c AND id=2480d890-c0cd-11e4-a691-df79ef55172c;

doesn't work in about half of cases silently (no errors I see in Cassandra logs, nothing suspicious in traces, no failure answer or exception, I can see that it didn't succeed just by SELECT). In case of cluster from one node, it always works.

Could you help me with some direction in case investigation?

解决方案

Since you mentioned that your nodes times aren't in sync, you may have a rare, but still possible condition.

If time is not in sync between the nodes, it may lead to some unpredictable results during the updates/inserts.

Usually when the write comes, the one with the latest timestamp wins. If one of your nodes has a time way behind, then when it becomes a coordinator, it stamps all of your records with its timestamps and therefore decides that this update is too old since there are already other updates with newer timestamp (from the nodes with accurate time). And therefore discards the update.

更多推荐

Cassandra更新无效地与几个节点

本文发布于:2023-08-07 10:28:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1318622.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:几个   节点   Cassandra

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!