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

Support SinceTs in iterators #1653

Merged
merged 8 commits into from
Feb 5, 2021
Merged

Support SinceTs in iterators #1653

merged 8 commits into from
Feb 5, 2021

Conversation

jarifibrahim
Copy link
Contributor

@jarifibrahim jarifibrahim commented Jan 25, 2021

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 Reviewable

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
Copy link
Contributor

@NamanJain8 NamanJain8 left a 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()

Copy link
Contributor

@NamanJain8 NamanJain8 left a 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 {
Copy link
Contributor Author

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]
Copy link
Contributor Author

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 {
Copy link
Contributor Author

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.

@jarifibrahim jarifibrahim merged commit 31c061e into master Feb 5, 2021
@jarifibrahim jarifibrahim deleted the ibrahim/sinceTs branch February 5, 2021 12:49
NamanJain8 added a commit that referenced this pull request Jul 8, 2021
)

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.
NamanJain8 added a commit that referenced this pull request Jul 8, 2021
)

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.

(cherry picked from commit 3911787)
NamanJain8 added a commit that referenced this pull request Jul 8, 2021
)

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.

(cherry picked from commit 3911787)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants