尽管可以删除SSTable,但数据仍然存在

时间:2018-04-06 09:48:44

标签: cassandra cassandra-3.0 cql3 cqlsh

我正在使用单个Cassandra 3.11.2节点(RHEL 6.5)。在密钥空间(名为' test')中,我有一个名为' test'的表。我通过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;

以下是表格:

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中的文件系统细节。

1 个答案:

答案 0 :(得分:2)

在linux上,文件名只是指向文件所在内存的指针(inode)。当Cassandra打开文件时,它会保存一个链接。使用rm删除文件时,删除从文件系统到物理内存的链接,但该文件仍由实时进程引用,因此不会被删除。您可以使用命令lsof轻松检查(列出打开的文件)。有一个标记列出给定的pid(用ps aux | grep cassandra检查cassandra pid)

显然,当你重新启动Cassandra时,文件会被删除。