我有一个cassandra表,想要删除一行,但是只有一列有一个特定的值。
即使Cassandra声称删除成功(它返回“applied:true”),消息仍然存在。
让我们创建表并插入一些数据:
CREATE TABLE IF NOT EXISTS test
(
id uuid PRIMARY KEY,
recipient text,
message text
);
INSERT INTO test (id, recipient, message)
VALUES (7ee055ee-b5dd-4bfd-b184-614d51e268d5, 'felix', 'foo');
INSERT INTO test (id, recipient, message)
VALUES (86c9d632-dc24-4635-8277-c987c78bd242, 'andrew', 'bar');
现在,我想删除一条消息,但前提是请求删除的用户(在本例中是felix)是收件人,因此具有执行此操作的权限:
cqlsh:service_message> DELETE FROM test WHERE id=7ee055ee-b5dd-4bfd-b184-614d51e268d5 IF recipient='felix';
[applied]
-----------
True
所以我现在认为查询确实成功了,但是如果我们查看表,就会发现消息仍然存在。
cqlsh:service_message> SELECT * FROM test;
id | message | recipient
--------------------------------------+---------+-----------
86c9d632-dc24-4635-8277-c987c78bd242 | bar | andrew
7ee055ee-b5dd-4bfd-b184-614d51e268d5 | foo | felix
(2 rows)
一些附加信息:
cqlsh 5.0.1 | Cassandra 3.11.2 | CQL spec 3.4.4 | Native protocol v4
cqlsh> DESCRIBE KEYSPACE service_message
CREATE KEYSPACE service_message WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '3'} AND durable_writes = true;
CREATE TABLE service_message.test (
id uuid PRIMARY KEY,
message text,
recipient 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';