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

Use txn.Get in addReverseMutation #3874

Merged
merged 2 commits into from
Aug 28, 2019
Merged

Conversation

animesh2049
Copy link
Contributor

@animesh2049 animesh2049 commented Aug 27, 2019

We cannot use txn.cache.GetFromDeltas for reverse mutations becasue
cache will not have deltas corresponding to reverse key. Fixes #3840


This change is Reviewable

We cannot use txn.cache.GetFromDeltas for reverse mutations becasue
cache will not have deltas corresponding to reverse key. Fixes #3840
Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ A review job has been created and sent to the PullRequest network.


@animesh2049 you can click here to see the review status or cancel the code review job.

Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change looks good to me assuming the tests are all passing. Nice work finding this and adding a test that would have caught the issue.


Reviewed with ❤️ by PullRequest

posting/index.go Outdated
@@ -169,7 +169,7 @@ func (txn *Txn) addReverseMutationHelper(ctx context.Context, plist *List,

func (txn *Txn) addReverseMutation(ctx context.Context, t *pb.DirectedEdge) error {
key := x.ReverseKey(t.Attr, t.ValueId)
plist, err := txn.cache.GetFromDelta(key)
plist, err := txn.Get(key)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be worth adding the comment from your description here in the code just to prevent someone from wondering if this can use GetFromDelta in the future?

Copy link

@gitlw gitlw 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 2 files reviewed, 3 unresolved discussions (waiting on @animesh2049, @manishrjain, and @martinmr)


dgraph/cmd/alpha/upsert_test.go, line 1434 at r1 (raw file):

	m1 := `
{
set {

It seems like the data set can be simplified to just between two nodes 2 and 3.


posting/index.go, line 172 at r1 (raw file):

func (txn *Txn) addReverseMutation(ctx context.Context, t *pb.DirectedEdge) error {
	key := x.ReverseKey(t.Attr, t.ValueId)
	plist, err := txn.Get(key)

Inside the runMutation function, there is a switch block to determine whether we should use the txn.Get or txn.GetFromDelta,
I feel this decision stored in the current getFn variable should be stored as a variable in the Txn object, and then used in all the other places where txn.Get or txn.GetFromDelta are required.

It's better for the decision to be concentrated to one place, so as to avoid random bugs like this.

Copy link
Contributor

@manishrjain manishrjain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 2 files at r1, 1 of 1 files at r2.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @gitlw, @martinmr, and @pullrequest[bot])


dgraph/cmd/alpha/upsert_test.go, line 1434 at r1 (raw file):

Previously, gitlw (Lucas Wang) wrote…

It seems like the data set can be simplified to just between two nodes 2 and 3.

Can you follow up with Animesh to get these addressed?


posting/index.go, line 172 at r1 (raw file):

Previously, gitlw (Lucas Wang) wrote…

Inside the runMutation function, there is a switch block to determine whether we should use the txn.Get or txn.GetFromDelta,
I feel this decision stored in the current getFn variable should be stored as a variable in the Txn object, and then used in all the other places where txn.Get or txn.GetFromDelta are required.

It's better for the decision to be concentrated to one place, so as to avoid random bugs like this.

We only have that knowledge here, because this logic knows if we're going to do the count index or not. Though, if you can think of a way to consolidate all that into one place, do raise a PR. For now, this seemed good enough (getting the release candidate out).


posting/index.go, line 172 at r1 (raw file):

Previously, pullrequest[bot] wrote…

Would it be worth adding the comment from your description here in the code just to prevent someone from wondering if this can use GetFromDelta in the future?

Added comments.

@manishrjain manishrjain merged commit c9f0af8 into master Aug 28, 2019
@manishrjain manishrjain deleted the animesh2049/issue-3840 branch August 28, 2019 02:34
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.

1.1.0-rc1: count selector at root ignores given value
3 participants