Cassandra-행을 삭제할 수 없습니다.
Casandra 테이블에서 특정 행 하나를 삭제하고 싶지만 할 수 없습니다. 나는 이것을 제외하고 테이블에서 다른 것을 삭제할 수 있습니다. 휴경 삭제 쿼리를 넣었지만 아무 일도 일어나지 않습니다.
cqlsh> delete from sales.tbl where orderid=999999 and orderdate='2019/01/01';
cqlsh>
cqlsh> select * from sales.tbl where orderid=999999 and orderdate='2019/01/01';
orderid | orderdate | country | itemtype | orderpriority | region | saleschannel | shipdate | totalcost | totalprofit | totalrevenue | unitcost | unitprice | unitssold
---------+------------+---------+----------+---------------+---------------+--------------+------------+-----------+-------------+--------------+----------+-----------+-----------
999999 | 2019/01/01 | Canada | Stuff | N | North America | Offline | 2019/01/02 | 100 | 0 | 100 | 0 | 1 | 1
(1 rows)
cqlsh>
이 표의 shema는 다음과 같습니다.
CREATE TABLE sales.tbl1 (
orderid bigint,
orderdate text,
country text,
itemtype text,
orderpriority text,
region text,
saleschannel text,
shipdate text,
totalcost float,
totalprofit float,
totalrevenue float,
unitcost float,
unitprice float,
unitssold int,
PRIMARY KEY (orderid, orderdate) ) WITH CLUSTERING ORDER BY (orderdate ASC)
AND bloom_filter_fp_chance = 0.01
AND caching = {'keys': 'ALL', 'rows_per_partition': 'ALL'}
AND comment = ''
AND compaction = {'class': 'SizeTieredCompactionStrategy'}
AND compression = {'sstable_compression': '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 = 1
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 = '99.0PERCENTILE';
어떠한 제안?
답변
이 기괴한 상황은 먼 미래에 타임 스탬프로 행이 생성 된 경우 발생할 수 있습니다. Cassandra 및 Scylla에서 클라이언트는 각 쓰기에 대한 타임 스탬프를 지정할 수 있으며 업데이트의 실제 시간 순서에 관계없이 최신 타임 스탬프가 우선합니다.
예를 들어 한 클라이언트가 타임 스탬프 1000으로 행을 쓰고 나중에 다른 클라이언트가 타임 스탬프 900에서 삭제를 보낸다고 가정합니다.이 삭제는 아무것도 삭제하지 않습니다. 쓰기는 삭제 후에 발생한 것으로 간주되므로 삭제는 무시됩니다.
이것이 바로 당신에게 일어난 일일 수 있습니다. 시계가 잘못 구성된 클라이언트가이 시계를 사용하고 먼 미래에 타임 스탬프가있는 행을 생성했습니다. 지금 시도 delete from sales.tbl where orderid=999999 and orderdate='2019/01/01';하면 현재 시간이이 삭제의 타임 스탬프로 사용되고 미래 타임 스탬프보다 오래되었으므로 삭제가 무시됩니다.
이것이 사실인지 확인하려면
select writetime(region) from sales.tbl where orderid=999999 and orderdate='2019/01/01';
그러면 항목에있는 "지역"열 (예 :)의 쓰기 시간 (예 : 타임 스탬프)이 표시됩니다. 이 시간은 UNIX 시대 (1970 년 1 월 1 일 자정 GMT) 이후 마이크로 초 단위입니다. 미래라면 문제를 올바르게 추측했습니다. 이 경우, 다음에 정말 이 행을 삭제, 당신은 다음과 같은 일을 할 필요가있을 것이다
delete from sales.tbl using timestamp 111111111 where orderid=999999 and orderdate='2019/01/01';
타임 스탬프 "111111111"은에서 select보여준 타임 스탬프보다 1 (적어도) 하나 높은 숫자 입니다.