cassandra tombstone导致写数据丢失问题征解

问题描述:

1.casssandra中数据结构:

ColumnFamily->Column->key-value(key,value,timestamp)

2.cassandra使用timestamp来判断数据的新旧。

3.cassandra删除column是通过写一个新column来实现的,这个column是tombstone。

4.如果添加一个tombstone到cassandra中删除一个column后,在tombstone还未被清除前,再次写入一个时间戳更小的相同column,此时会导致这次的写入成功但用户查询不到该次写入的column。

clue

--------------------------------

how can i get a tombstone’s timestamp?

I understand that tombstones are internal implementation detail ... yet, the fact remains in 0.6.2 that a key/col creation followed by a delete of the key/col will result in the key being returned in a get_range_slices call. If the CF is flushed and compacted (after GCGraceSeconds), the key will not be returned in the get_range_slices call.
++
1.如果有tombstone存在,数据返回遵守读一致性级别,即取R份一致的数据后返回。2.如果写tombstone后,一直没有进行flush+compacted操作,有没有其他的操作会保证数据的一致性(read repair?)3.怎么才能获取到写入的tombstone(column)的时间戳?cassandra二次开发?
这个问题非常重要,是解决我们问题的关键。目前进展:
通过查看cassandra0.7.5源码,发现cassandra的删除column是通过写入tombstone 这样一个实现了IColumn接口的对象,
所以tombstone中必定包含所有IColumn的方法。
1.目前猜是想在获取tombstone对象是通过封装做了后台的判断,如果是tomestone直接返回null,若此则修改让tombstone能正常返回。
2.
org.apache.cassandra.db.DeletedColumn

@Override
public long getMarkedForDeleteAt()
{
return timestamp;
}

@Override
public int getLocalDeletionTime()
{
return value.getInt(value.position());
}

:明确两个方法到底返回的是什么时间,区别:
getMarkedForDeleteAt()
getLocalDeletionTime()

+++++

hector source code:

https://github.com/rantav/hector/downloads

[@more@]

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/23937368/viewspace-1052615/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/23937368/viewspace-1052615/

你可能感兴趣的:(cassandra tombstone导致写数据丢失问题征解)