Я не могу понять, как счетчики Кассандры хранятся на диске.
Создать тестовую таблицу
create table testcounter (
id text,
count counter,
PRIMARY KEY(id))
WITH 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'}
Добавить данные
update testcounter set count = count + 10 where id = 'testrow';
Проверьте sstable
nodetool flush test testcounter
sstabledump /usr/local/var/lib/cassandra/data/test/testcounter-87d6ae20908e11e9a5779f988085883a/mc-1-big-Data.db
Ответ от sstabledump
[
{
"partition" : {
"key" : [ "testrow" ],
"position" : 0
},
"rows" : [
{
"type" : "row",
"position" : 63,
"cells" : [
{ "name" : "count", "value" : 422215477737628, "tstamp" : "2019-06-16T23:30:34.423470Z" }
]
}
]
}
Обновить существующие данные
update testcounter set count = count + 10 where id = 'testrow';
update testcounter set count = count + 10 where id = 'testrow';
Flush
nodetool flush test testcounter
На данный момент существует два набора файлов БД.
ls /usr/local/var/lib/cassandra/data/test/testcounter-87d6ae20908e11e9a5779f988085883a/
backups mc-1-big-Digest.crc32 mc-1-big-Statistics.db mc-2-big-CompressionInfo.db mc-2-big-Filter.db mc-2-big-Summary.db
mc-1-big-CompressionInfo.db mc-1-big-Filter.db mc-1-big-Summary.db mc-2-big-Data.db mc-2-big-Index.db mc-2-big-TOC.txt
mc-1-big-Data.db mc-1-big-Index.db mc-1-big-TOC.txt mc-2-big-Digest.crc32 mc-2-big-Statistics.db
sstabledump для mc-1
[
{
"partition" : {
"key" : [ "testrow" ],
"position" : 0
},
"rows" : [
{
"type" : "row",
"position" : 63,
"cells" : [
{ "name" : "count", "value" : 422215477737628, "tstamp" : "2019-06-16T23:30:34.423470Z" }
]
}
]
}
sstabledump для mc-2
[
{
"partition" : {
"key" : [ "testrow" ],
"position" : 0
},
"rows" : [
{
"type" : "row",
"position" : 65,
"cells" : [
{ "name" : "count", "value" : 422215477737628, "tstamp" : "2019-06-16T23:34:37.245893Z" }
]
}
]
}
Похоже, что надгробий нет, и даже значения счетчиков не сохраняются. Что происходит за кадром?