Cassandra版本: 3.11.2
我观察到,如果我尝试将数据从某些修改之前捕获的快照(通过alter命令)恢复到表中,则数据无法正确恢复。对于例如我在2节点设置上执行了以下操作:
CREATE KEYSPACE test WITH replication = {'class': 'NetworkTopologyStrategy', 'dc1': '2'} AND durable_writes = true;
CREATE TABLE test.backup_test (
name text PRIMARY KEY,
age int
) WITH 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';
创建上述内容后,我在表格中输入了几行。
name | age
---------+-----
Saurabh | 25
Zaid | 23
Vishal | 24
现在,我使用nodetool实用程序捕获此表的快照。
在此之后,我改变了表格,如:
alter table backup_test drop age ;
alter table backup_test add age int;
然后我截断了表格:
truncate table backup_test ;
现在我恢复了快照并执行了nodetool刷新:
nodetool refresh test backup_test
但这是我得到的数据:
name | age
---------+------
Saurabh | null
Zaid | null
Vishal | null
如您所见,'age'列在恢复后没有获得任何数据。我无法理解为什么会这样。但是,如果我在恢复之前删除表,然后重新创建表,那么我会得到正确的数据。