更新的数据仍然存在于CQL表中

时间:2015-03-05 08:35:06

标签: cassandra bigdata cql3

我使用CQL创建了一个使用SET作为列的表。

CREATE TABLE z_test.activity_follow (
    activity_type_id text,
    error_message text,
    error_type text,
    file text,
    line_no text,
    project_api_key text,
    project_name text,
    project_party_id text,
    release_stage_id text,
    stage_name text,
    project_type_name text,
    activity_type_name text,
    account_id text,
    created_at text,
    secure_url text,
    error_count text,
    user_id set<text>,
    PRIMARY KEY (activity_type_id,error_message,error_type,file,line_no,project_api_key,project_name,project_party_id,release_stage_id,stage_name,project_type_name,activity_type_name,account_id,created_at,secure_url)
);

z_test是我的键空间。 然后我使用以下查询

将一个值插入表中
UPDATE z_test.activity_follow SET user_id = user_id + {'46'} , error_count = '4' 
                               WHERE  activity_type_id = '1'
                                         AND error_message = '1'
                                         AND error_type = '1'
                                         AND FILE = '1'
                                         AND line_no = '1'
                                         AND project_api_key = '1'
                                         AND project_name = '1'
                                         AND project_party_id = '1'
                                         AND release_stage_id = '1'
                                         AND stage_name = '1'
                                         AND project_type_name = '1'
                                         AND activity_type_name = '1'
                                         AND account_id = '1'
                                         AND secure_url = '1'
                                         AND created_at = '1'




UPDATE z_test.activity_follow SET user_id = user_id + {'464'} , error_count = '4'
                               WHERE  activity_type_id = '1'
                                         AND error_message = '1'
                                         AND error_type = '1'
                                         AND FILE = '1'
                                         AND line_no = '1'
                                         AND project_api_key = '1'
                                         AND project_name = '1'
                                         AND project_party_id = '1'
                                         AND release_stage_id = '1'
                                         AND stage_name = '1'
                                         AND project_type_name = '1'
                                         AND activity_type_name = '1'
                                         AND account_id = '1'
                                         AND secure_url = '1'
                                         AND created_at = '1'

成功插入值。我使用了以下select语句,

SELECT * FROM z_test.users WHERE emails CONTAINS 'test@mail.com';

我得到了以下结果,

 activity_type_id | error_message                      | error_type     | file                                                               | line_no | project_api_key                      | project_name             | project_party_id | release_stage_id | stage_name  | project_type_name | activity_type_name | account_id | created_at          | secure_url                                      | error_count | user_id
------------------+------------------------------------+----------------+--------------------------------------------------------------------+---------+--------------------------------------+--------------------------+------------------+------------------+-------------+-------------------+--------------------+------------+---------------------+-------------------------------------------------+-------------+---------
                1 | alebvevcbvghhgrt123 is not defined | ReferenceError | http://localhost/ems-sdk/netspective_ems_js/example/automatic.html |      19 | 8aec5ce3-e924-3090-9bfe-57a440feba5f | Prescribewell-citrus-123 |               48 |                4 | Development |               Php |          exception |         47 | 2015-03-03 04:04:23 | PRE-EX-429c3daae9c108dffec32f113b9ca9cff1bb0468 |           1 |  {'464'}

然后我使用

从表格中删除了一封电子邮件
UPDATE z_test.activity_follow SET user_id = user_id - {'46'} , error_count = '4' 
                               WHERE  activity_type_id = '1'
                                         AND error_message = '1'
                                         AND error_type = '1'
                                         AND FILE = '1'
                                         AND line_no = '1'
                                         AND project_api_key = '1'
                                         AND project_name = '1'
                                         AND project_party_id = '1'
                                         AND release_stage_id = '1'
                                         AND stage_name = '1'
                                         AND project_type_name = '1'
                                         AND activity_type_name = '1'
                                         AND account_id = '1'
                                         AND secure_url = '1'
                                         AND created_at = '1'

现在,当我使用上述查询时,

SELECT * FROM z_test.activity_follow WHERE user_id CONTAINS '46';

它仍然会返回行

   activity_type_id | error_message                      | error_type     | file                                                               | line_no | project_api_key                      | project_name             | project_party_id | release_stage_id | stage_name  | project_type_name | activity_type_name | account_id | created_at          | secure_url                                      | error_count | user_id
------------------+------------------------------------+----------------+--------------------------------------------------------------------+---------+--------------------------------------+--------------------------+------------------+------------------+-------------+-------------------+--------------------+------------+---------------------+-------------------------------------------------+-------------+---------
                1 | alebvevcbvghhgrt123 is not defined | ReferenceError | http://localhost/ems-sdk/netspective_ems_js/example/automatic.html |      19 | 8aec5ce3-e924-3090-9bfe-57a440feba5f | Prescribewell-citrus-123 |               48 |                4 | Development |               Php |          exception |         47 | 2015-03-03 04:04:23 | PRE-EX-429c3daae9c108dffec32f113b9ca9cff1bb0468 |           1 |  {'464'}

为什么我会出现这种行为?是在CQL中预期的吗?如果我可以删除这个怎么样?我已将每个值都作为1进行测试,我也尝试了其他值。

1 个答案:

答案 0 :(得分:3)

您使用什么客户端来执行CQL语句?这都是在cqlsh或其他地方完成的吗?

这只是一个黑暗猜测的镜头,但如果你运行两个CQL语句快速匹配相同的主键,它们可能会在cassandra中被赋予相同的写入时间,这意味着其中一个突变将被忽略

请参阅:Cassandra: Writes after setting a column to null are lost randomly. Is this a bug, or I am doing something wrong?

如果您正在运行Cassandra 2.1.2+ cassandra现在会在相同的毫秒(CASSANDRA-6123

处写入/更新时断开连接