多个节点的 Cassandra 更新静默失败

Cassandra update fails silently with several nodes

我有以下情况。

有一个 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'};

并使用 datastax-java-driver (cassandra-driver-core 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;

在大约一半的情况下没有默默地工作(我在 Cassandra 日志中没有看到错误,痕迹中没有可疑的东西,没有失败答案或异常,我可以看到它没有成功只是 SELECT).如果从一个节点集群,它总是有效。

你能帮我指导一下案件调查吗?

既然你提到你的节点时间不同步,你可能遇到了一种罕见但仍有可能的情况。

如果节点之间的时间不同步,可能会导致updates/inserts期间出现一些不可预知的结果。

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