【问题标题】:Deleted data in cassandra come back,like ghostcassandra中删除的数据像幽灵一样回来了
【发布时间】:2019-01-02 22:33:44
【问题描述】:

我有一个 3 节点 Cassandra 集群(3.7),一个键空间

CREATE KEYSPACE demo WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '2'}  AND durable_writes = true;

一张桌子

CREATE TABLE tradingdate (key text,tradingdate date,PRIMARY KEY (key, tradingdate));

有一天删除一行喜欢

delete from tradingdate 
where key='tradingDay'and tradingdate='2018-12-31'

那么查询时删除的行就变成ghost了

select * from tradingdate 
where key='tradingDay'and tradingdate>'2018-12-27' limit 2;

     key        | tradingdate
    ------------+-------------
     tradingDay |  2018-12-28
     tradingDay |  2019-01-02


select * from tradingdate 
where key='tradingDay'and tradingdate<'2019-01-03' 
order by tradingdate desc limit 2;

     key        | tradingdate
    ------------+-------------
     tradingDay |  2019-01-02
     tradingDay |  2018-12-31

所以当使用 order by 时,删除的行 (tradingDay, 2018-12-31) 又回来了。

我想我只删除了一个节点上的一行,但它仍然存在于另一个节点上。所以我执行:

nodetool repair demo tradingdate

在 3 个节点上,然后删除的行完全消失

所以我想知道为什么要使用order by,我可以看到鬼行。

【问题讨论】:

  • 什么版本的 cassandra?
  • 阅读时使用的一致性级别是多少?
  • 我在cqlsh中执行查询,默认一致性是ONE。我记得我曾经遇到过这种情况,当设置一致性2时,会导致相同的结果
  • 这可能是原因。您的删除不会传播到其他节点,并且在一致性 ONE 下,您可能会读取过时的数据。尝试使用 QUORUM 以获得更高的一致性。
  • 但奇怪的是,当不使用 order by 时,我无法获取陈旧数据

标签: cassandra nosql


【解决方案1】:

这是一些关于 Cassandra(以及其他分布式系统)中删除的好读物:

http://thelastpickle.com/blog/2016/07/27/about-deletes-and-tombstones.html

还有:

https://docs.datastax.com/en/cassandra/3.0/cassandra/dml/dmlAboutDeletes.html

您需要在gc_grace_seconds 内至少运行/安排一次例行修复,默认为十天,以防止数据重新出现在您的集群中。

如果您的节点之一丢失删除(和其他消息),您还应该查找丢弃的消息:

# nodetool tpstats
Pool Name                    Active   Pending      Completed   Blocked  All time blocked
MutationStage                     0         0      787032744         0                 0
ReadStage                         0         0     1627843193         0                 0
RequestResponseStage              0         0     2257452312         0                 0
ReadRepairStage                   0         0       99910415         0                 0
CounterMutationStage              0         0              0         0                 0
HintedHandoff                     0         0           1582         0                 0
MiscStage                         0         0              0         0                 0
CompactionExecutor                0         0        6649458         0                 0
MemtableReclaimMemory             0         0          17987         0                 0
PendingRangeCalculator            0         0             46         0                 0
GossipStage                       0         0       22766295         0                 0
MigrationStage                    0         0              8         0                 0
MemtablePostFlush                 0         0         127844         0                 0
ValidationExecutor                0         0              0         0                 0
Sampler                           0         0              0         0                 0
MemtableFlushWriter               0         0          17851         0                 0
InternalResponseStage             0         0           8669         0                 0
AntiEntropyStage                  0         0              0         0                 0
CacheCleanupExecutor              0         0              0         0                 0
Native-Transport-Requests         0         0      631966060         0                19

Message type           Dropped
READ                         0
RANGE_SLICE                  0
_TRACE                       0
MUTATION                     0
COUNTER_MUTATION             0
REQUEST_RESPONSE             0
PAGED_RANGE                  0
READ_REPAIR                  0

丢弃的消息表明有问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-03
    • 1970-01-01
    • 2020-12-27
    • 1970-01-01
    • 2022-01-01
    • 1970-01-01
    相关资源
    最近更新 更多