Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

seekForPrev not suppoert ReadOptions'setIterStartSeqnum() #8472

Open
Cicizz opened this issue Jun 30, 2021 · 2 comments
Open

seekForPrev not suppoert ReadOptions'setIterStartSeqnum() #8472

Cicizz opened this issue Jun 30, 2021 · 2 comments
Labels
up-for-grabs Up for grabs

Comments

@Cicizz
Copy link

Cicizz commented Jun 30, 2021

when i use seekForPrev,i want to skip some key,but setIterStartSeqnum() method is not valid.

@jay-zhuang
Copy link
Contributor

jay-zhuang commented Oct 14, 2021

What do you mean SetIterStartSeqnum() is not valid?
I tested cpp code, seems SeekForPrev() doesn't work well with ReadOptions.iter_start_seqnum, here is a test which throws an assert exception:

TEST_P(DBIteratorTest, IterSeekForPrevBeforeNext) {
  ASSERT_OK(Put("a", "b"));
  auto seq = db_->GetLatestSequenceNumber();
  ASSERT_OK(Put("c", "d"));
  EXPECT_OK(dbfull()->Flush(FlushOptions()));
  ASSERT_OK(Put("0", "f"));
  ASSERT_OK(Put("1", "h"));
  EXPECT_OK(dbfull()->Flush(FlushOptions()));
  ASSERT_OK(Put("2", "j"));
  auto ro = ReadOptions();
  ro.iter_start_seqnum = seq;
  auto iter = NewIterator(ro);
  iter->SeekForPrev(Slice("0"));
  if (iter->Valid()) {
    std::cout << iter->key().ToString() << std::endl; // exception
  }
  delete iter;
}

https://github.com/jay-zhuang/rocksdb/blob/089e9af7a15404096bce60c6d210781d52f5d4d8/db/db_iterator_test.cc#L216

@jay-zhuang jay-zhuang added the up-for-grabs Up for grabs label Oct 14, 2021
@jay-zhuang
Copy link
Contributor

Currently iter_start_seqnum feature is not well maintained, as an alternative, you can use user-defined timestamp feature to filter out the data, which is much more flexible to use: https://github.com/facebook/rocksdb/wiki/User-Timestamp-%28Experimental%29

jay-zhuang added a commit to jay-zhuang/rocksdb that referenced this issue Nov 19, 2021
Summary:
`ReadOptions::iter_start_seqnum` and `DBOptions::preserve_deletes` are
deprecated, please try using user defined timestamp feature instead.
The feature is used to support differential snapshots, but not well
maintained (facebook#6837, facebook#8472) and the interface is not user friendly which
returns an internal key from the iterator. The user defined timestamp
feature is a more flexible feature to support similar usecase, please
switch to that if you have such usecase.
The deprecated feature will be removed in a future release.

Test Plan: check LOG

Fix facebook#9090
facebook-github-bot pushed a commit that referenced this issue Nov 20, 2021
Summary:
`ReadOptions::iter_start_seqnum` and `DBOptions::preserve_deletes` are
deprecated, please try using user defined timestamp feature instead.
The feature is used to support differential snapshots, but not well
maintained (#6837, #8472) and the interface is not user friendly which
returns an internal key from the iterator. The user defined timestamp
feature is a more flexible feature to support similar usecase, please
switch to that if you have such usecase.
The deprecated feature will be removed in a future release.

Pull Request resolved: #9091

Test Plan:
check LOG

Fix #9090

Reviewed By: ajkr

Differential Revision: D32071750

Pulled By: jay-zhuang

fbshipit-source-id: b882c4668dd1bf26ce03c4c192f1bba584bf6104
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
up-for-grabs Up for grabs
Projects
None yet
Development

No branches or pull requests

2 participants