有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';
您可以包括表種類包括完整的模式? –
我已經包含模式與類型,如果這說的更多.. –