2015-03-02 27 views
2

我有以下情况。Cassandra更新以几个节点静默失败

有一个CQL表(卡桑德拉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'}; 

,并用它与datastax-java的驱动器(卡桑德拉驱动器芯2.1.1)

当群集包含3工作节点的数据更新,像

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; 

并不在大约一半默默的情况下工作(没有错误我在卡桑德拉日志中看到,在没有任何可疑的痕迹,没有失败的回答或异常,我可以看到它没”只需通过SELECT成功)。如果来自一个节点的集群,它始终有效。

你能帮我带点案件调查方向吗?

+2

你是什么意思,它不起作用?你一遍又一遍地插入这条记录吗?你究竟通过SELECT检查了什么? – phact 2015-03-02 14:41:20

+0

什么是密钥空间复制因子?插入一致性级别是什么?什么是你的阅读一致性水平? – 2015-03-02 21:52:10

+0

@phact,是的,我将记录插入现有密钥(实际上使用插入语法进行更新)并通过主键进行选择。反复在大约一半的情况下插入不报告任何问题,但随之而来的选择显示没有更新的记录 – 2015-03-03 15:32:43

回答

5

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

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

通常,当写入时,具有最新时间戳的那个获胜。如果其中一个节点有时间延迟,那么当它成为一个协调器时,它会用所有时间戳标记所有记录,并因此确定此更新已过时,因为已经有更新的时间戳(来自节点准确的时间)。因此放弃更新。

+1

使用NTP ! http://www.datastax.com/documentation/cassandra/2.0/cassandra/install/installRecommendSettings.html?scroll=reference_ds_sxl_gf3_2k__synchronize-clocks – phact 2015-03-06 15:08:31

+0

时间差异会使这种情况发生多少?以毫秒为单位的差异会导致此问题? – Amit 2016-03-11 10:25:47

+0

在边缘情况下,当两次插入/更新在相互毫秒之内时,以毫秒为单位的差异可能导致此问题。 – 2016-03-15 06:39:20