-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Support SinceTs in iterators #1653
Conversation
SinceTs can be used to read data above a particular timestamp. All data less with version less than the sinceTs will be ignored. SinceTs is always less than the readTs and when sinceTs is set, the data between sinceTs and readTs will be read. sinceTs <= data to be read <= readTs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 5 files reviewed, 2 unresolved discussions (waiting on @jarifibrahim and @manishrjain)
iterator.go, line 399 at r1 (raw file):
hash := y.Hash(opt.Prefix) for _, t := range filtered { if t.MaxVersion() < opt.SinceTs {
If the prefix is set to nil
then we will end up picking all the tables.
iterator_test.go, line 149 at r1 (raw file):
iopt.SinceTs = sinceTs db.View(func(txn *Txn) error {
require.NoError()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 5 files reviewed, 1 unresolved discussion (waiting on @jarifibrahim and @manishrjain)
@@ -68,11 +69,6 @@ func (stream *Stream) Backup(w io.Writer, since uint64) (uint64, error) { | |||
if !bytes.Equal(item.Key(), key) { | |||
return list, nil | |||
} | |||
if item.Version() < since { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log an error if this happens.
iterator.go
Outdated
allCopy := make([]*table.Table, len(all)) | ||
copy(allCopy, all) | ||
if opt.SinceTs > 0 { | ||
tmp := allCopy[:0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This filtering should be the last step in pickTables.
iterator.go
Outdated
@@ -610,7 +623,8 @@ func (it *Iterator) parseItem() bool { | |||
|
|||
// Skip any versions which are beyond the readTs. | |||
version := y.ParseTs(key) | |||
if version > it.readTs { | |||
// Ignore everything that is above the readTs and below the sinceTs. | |||
if version > it.readTs || version < it.opt.SinceTs { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't include the data at the sinceTs.
) With the introduction of SinceTs, a bug was introduced #1653 that skips the pending entries. The default value of SinceTs is zero. And for the transaction made at readTs 0, the pending entries have version set to 0. So they were also getting skipped.
SinceTs can be used to read data above a particular timestamp. All data
less with version less than the sinceTs will be ignored.
SinceTs is always less than the readTs and when sinceTs is set, the
data between sinceTs and readTs will be read.
sinceTs < data to be read <= readTs
Fixes DGRAPH-2958
This change is