Cassandra具有多行,具有相同的分区和集群密钥

问题描述:

有5个节点的Cassandra集群。最近,逐节点地完成了从2.2.7版到3.9版的更新。更新根据Datastax描述的过程完成:upgrade instruction。一切顺利。整个过程花费了1个小时。 但是,几个小时后,我发现以下问题: 更新期间某些数据不一致,即对于特定的分区键和集群键1,应只返回一行。但有时会有一个,有时会返回两个 - 用于相同的查询。Cassandra具有多行,具有相同的分区和集群密钥

该表有以下PRIMARY KEY: ((id, year), date time)。所以,查询

SELECT * FROM table_name 
    WHERE id=1 and year=2017 and datetime='2017-01-01T01:01:01:000Z'; 

有时会返回一个,有时两个行。

此外,这些行是不同的,只有主键的字段是相同的。

结果例如:

id | year | datetime    | field1 | field2 | field3 | field4 
---+------+-------------------------+--------+--------+--------+-------- 
1 | 2017 | 2017-01-01 01:01:01.000 | null | null |  5 |  6 
1 | 2017 | 2017-01-01 01:01:01.000 |  3 |  4 | null | null 

所以,当你看到第一排有字段:字段3和,而第二有FIELD1和FIELD2 NOT NULL字段4不为空。相同的模式适用于其余损坏的数据。

此外,一旦我尝试删除这些行,只有第一个消失,第二个保持不变。我相信字段'datetime'是相同的,这不是毫秒问题,因为blobAsBigint(timestampAsBlob(datetime))为两行返回相同的值。

做了什么:

nodetool upgradesstables my_keyspace(每个节点逐个)

nodetool修复my_keyspace(每个节点逐个)被要求

upgradesstable因为最初修复返回“验证失败”错误: https://support.datastax.com/hc/en-us/articles/205256895--Validation-failed-when-running-a-nodetool-repair

CREATE TABLE my_keyspace.my_table (
    id bigint, 
    year int, 
    datetime timestamp, 
    field1 int, 
    field2 int, 
    field3 set<bigint>, 
    field4 boolean, 
    field5 map<int, text>, 
    field6 timestamp, 
    field7 decimal, 
    field8 decimal, 
    PRIMARY KEY ((id, year), datetime) 
) WITH CLUSTERING ORDER BY (datetime ASC) 
    AND bloom_filter_fp_chance = 0.01 
    AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} 
    AND comment = '' 
    AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} 
    AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} 
    AND crc_check_chance = 1.0 
    AND dclocal_read_repair_chance = 0.1 
    AND default_time_to_live = 0 
    AND gc_grace_seconds = 864000 
    AND max_index_interval = 2048 
    AND memtable_flush_period_in_ms = 0 
    AND min_index_interval = 128 
    AND read_repair_chance = 0.0 
    AND speculative_retry = '99PERCENTILE'; 
+0

您可以包括表种类包括完整的模式? –

+0

我已经包含模式与类型,如果这说的更多.. –

升级到3.11并执行nodetool scrub。有固定在3.0.11和3.11

见移植这就是一个错误:https://issues.apache.org/jira/browse/CASSANDRA-13125的细节