Cassandra更新无效地与几个节点 [英] Cassandra update fails silently with several nodes

查看:133
本文介绍了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更新无效地与几个节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆