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

Q: How to access the sequence number of an entry? #325

Closed
nlfiedler opened this issue Sep 3, 2019 · 5 comments · Fixed by #326
Closed

Q: How to access the sequence number of an entry? #325

nlfiedler opened this issue Sep 3, 2019 · 5 comments · Fixed by #326

Comments

@nlfiedler
Copy link
Contributor

Seems like RocksDB tags every entry with a monotonically increasing sequence number, and there might be some means of accessing that. In fact, it looks like getting a snapshot should return the current sequence number. Is this exposed somewhere in rust-rocksb and I just can't find it? Thanks for your help.

@vitvakatu
Copy link

Does the RocksDB itself exposes this functionality? rust-rocksdb is just a binding and will not expose anything that is unavailable in a parent library.

@nlfiedler
Copy link
Contributor Author

Sorry, I should have looked for a reference sooner. Admittedly I'm not that good at reading large C code bases any more, but it looks like there are a couple of functions related to sequence numbers. There's GetLatestSequenceNumber() in include/rocksdb/db.h and another function named rocksdb_get_latest_sequence_number() in db/c.cc that invokes it. There are also numerous tests invoking GetLatestSequenceNumber() so maybe that's the public function? Again, not too good at reading large C code bases in short order.

@vitvakatu
Copy link

Thank you for a little investigation. This function is indeed exists in a public API (and Java bindings exports it as well). It would be fairly easy to add. If you want, you can send a PR (or I can do it myself).

@nlfiedler
Copy link
Contributor Author

You're much better off not letting me touch the code. :)

@nlfiedler
Copy link
Contributor Author

Fantastic, thank you. The reason I asked about the sequence number is that I want to implement a secondary index in RocksDB, and the sequence number is a very good way to detect stale index records. The project is here, https://github.com/nlfiedler/mokuroku -- still needs a lot of work though.

BusyJay pushed a commit to BusyJay/rust-rocksdb that referenced this issue Jul 23, 2020
Cherry-picking the following changes that fixes zlib, jemalloc and gflags dependencies, and fixes a flaky test:
```
6ead62c 2019-07-25 yiwu@pingcap.com     Avoid build require system zlib (rust-rocksdb#303)
9246b9c 2019-07-25 hi@breeswish.org     Skip jemalloc options on specific platform (rust-rocksdb#324)
7a8dd73 2019-07-22 yiwu@pingcap.com     Add jemalloc-sys dependency when jemalloc is enabled (rust-rocksdb#320)
6f2c632 2019-07-23 yiwu@pingcap.com     Not compile with gflags (rust-rocksdb#322)
09b8032 2019-07-22 yiwu@pingcap.com     Fix perf context test (rust-rocksdb#321)
d67f38e 2019-07-21 yiwu@pingcap.com     Add jemalloc feature (rust-rocksdb#319)
```

Also update rocksdb to fix compile error with gcc9:
```
7a03c83ed 2019-07-23 psergey@askmonty.org Fix MyRocks compile warnings-treated-as-errors on Fedora 30, gcc 9.1.1 (#5553)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants