尽管删除了 SSTable,但数据仍然存在
Data present despite SSTable deletion
我正在处理单个 Cassandra 3.11.2 节点 (RHEL 6.5)。在键空间(名为 'test')中,我有一个名为 'test' 的 table。我通过 cqlsh 输入了一些行,然后 然后执行了 nodetool flush。 我检查了数据目录以确认已创建 SSTable。现在我删除了所有 .db 文件(使用 rm *.db 从 test.test 数据目录)。
奇怪的是,我仍然可以在 cqlsh 中看到所有行!我不明白,这是怎么回事,因为我手动删除了 SSTable。
下面是我的键空间:
CREATE KEYSPACE test WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'} AND durable_writes = true;
下面给出的是 table:
CREATE TABLE test.test (
aadhar_number int PRIMARY KEY,
address text,
name text
) 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';
下面是 nodetool tablestats 命令的输出(在我删除了 SSTable 之后):
Keyspace : test
Read Count: 0
Read Latency: NaN ms
Write Count: 13
Write Latency: 0.11269230769230769 ms
Pending Flushes: 0
Table: test
SSTable count: 1
Space used (live): 5220
Space used (total): 5220
Space used by snapshots (total): 0
Off heap memory used (total): 48
SSTable Compression Ratio: 0.7974683544303798
Number of partitions (estimate): 255
Memtable cell count: 0
Memtable data size: 0
Memtable off heap memory used: 0
Memtable switch count: 4
Local read count: 0
Local read latency: NaN ms
Local write count: 10
Local write latency: NaN ms
Pending flushes: 0
Percent repaired: 0.0
Bloom filter false positives: 0
Bloom filter false ratio: 0.00000
Bloom filter space used: 24
Bloom filter off heap memory used: 16
Index summary off heap memory used: 16
Compression metadata off heap memory used: 16
Compacted partition minimum bytes: 18
Compacted partition maximum bytes: 50
Compacted partition mean bytes: 36
Average live cells per slice (last five minutes): 5.0
Maximum live cells per slice (last five minutes): 5
Average tombstones per slice (last five minutes): 1.0
Maximum tombstones per slice (last five minutes): 1
Dropped Mutations: 0
我重新启动了 Cassandra,然后数据才停止显示在 cqlsh 中。
非常好的 article 用于了解 linux 中的文件系统详细信息。
在 linux 上,文件名只是指向文件所在内存的指针(inode)。当 Cassandra 打开文件时,它会保存一个 link 到它。当您使用 rm 删除文件时,您将 link 从文件系统删除到物理内存,但该文件仍被实时进程引用,因此不会被删除。您可以使用命令 lsof
(列出打开的文件)轻松检查。有一个要列出给定 pid 的标志(用 ps aux | grep cassandra
之类的东西检查 cassandra pid)
显然,当您重新启动 Cassandra 时,文件会被删除。
我正在处理单个 Cassandra 3.11.2 节点 (RHEL 6.5)。在键空间(名为 'test')中,我有一个名为 'test' 的 table。我通过 cqlsh 输入了一些行,然后 然后执行了 nodetool flush。 我检查了数据目录以确认已创建 SSTable。现在我删除了所有 .db 文件(使用 rm *.db 从 test.test 数据目录)。 奇怪的是,我仍然可以在 cqlsh 中看到所有行!我不明白,这是怎么回事,因为我手动删除了 SSTable。
下面是我的键空间:
CREATE KEYSPACE test WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'} AND durable_writes = true;
下面给出的是 table:
CREATE TABLE test.test (
aadhar_number int PRIMARY KEY,
address text,
name text
) 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';
下面是 nodetool tablestats 命令的输出(在我删除了 SSTable 之后):
Keyspace : test
Read Count: 0
Read Latency: NaN ms
Write Count: 13
Write Latency: 0.11269230769230769 ms
Pending Flushes: 0
Table: test
SSTable count: 1
Space used (live): 5220
Space used (total): 5220
Space used by snapshots (total): 0
Off heap memory used (total): 48
SSTable Compression Ratio: 0.7974683544303798
Number of partitions (estimate): 255
Memtable cell count: 0
Memtable data size: 0
Memtable off heap memory used: 0
Memtable switch count: 4
Local read count: 0
Local read latency: NaN ms
Local write count: 10
Local write latency: NaN ms
Pending flushes: 0
Percent repaired: 0.0
Bloom filter false positives: 0
Bloom filter false ratio: 0.00000
Bloom filter space used: 24
Bloom filter off heap memory used: 16
Index summary off heap memory used: 16
Compression metadata off heap memory used: 16
Compacted partition minimum bytes: 18
Compacted partition maximum bytes: 50
Compacted partition mean bytes: 36
Average live cells per slice (last five minutes): 5.0
Maximum live cells per slice (last five minutes): 5
Average tombstones per slice (last five minutes): 1.0
Maximum tombstones per slice (last five minutes): 1
Dropped Mutations: 0
我重新启动了 Cassandra,然后数据才停止显示在 cqlsh 中。
非常好的 article 用于了解 linux 中的文件系统详细信息。
在 linux 上,文件名只是指向文件所在内存的指针(inode)。当 Cassandra 打开文件时,它会保存一个 link 到它。当您使用 rm 删除文件时,您将 link 从文件系统删除到物理内存,但该文件仍被实时进程引用,因此不会被删除。您可以使用命令 lsof
(列出打开的文件)轻松检查。有一个要列出给定 pid 的标志(用 ps aux | grep cassandra
之类的东西检查 cassandra pid)
显然,当您重新启动 Cassandra 时,文件会被删除。