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

delete item immediately #113

Merged
merged 6 commits into from
Jan 15, 2020
Merged

delete item immediately #113

merged 6 commits into from
Jan 15, 2020

Conversation

poonai
Copy link
Contributor

@poonai poonai commented Dec 20, 2019

Delete was happening concurrently in a separate goroutine. This will make the delete happen immediately But the pitfall is that if there is a set in the channel it'll bring the item again. So, we're pushing to the channel as well to maintain the order.
Signed-off-by: balaji balaji@dgraph.io


This change is Reviewable

Signed-off-by: balaji <balaji@dgraph.io>
balaji added 2 commits December 20, 2019 16:33
Signed-off-by: balaji <balaji@dgraph.io>
Signed-off-by: balaji <balaji@dgraph.io>
@jarifibrahim
Copy link
Contributor

This PR needs a description.

@poonai
Copy link
Contributor Author

poonai commented Dec 26, 2019

@jarifibrahim updated

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.

No. This shouldn't happen. In fact, please do add this following explanation as a comment.

If we have pushed a Set to a channel, it would be applied slightly later. In current code, if a deletion immediately follows that Set, it would be applied in the same order. With this PR, the deletion would be applied before the Set, which would be wrong.

Please do add a comment of that nature. CC: @karlmcguire to verify my understanding.

:lgtm_cancel:

Reviewable status: 0 of 3 files reviewed, all discussions resolved (waiting on @jarifibrahim, @karlmcguire, and @manishrjain)

Signed-off-by: balaji <balaji@dgraph.io>
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.

:lgtm: Do address the comment.

Reviewed 2 of 3 files at r1, 1 of 1 files at r2.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @balajijinnah, @jarifibrahim, and @karlmcguire)


cache.go, line 220 at r2 (raw file):

	keyHash, conflictHash := c.keyToHash(key)
	c.store.Del(keyHash, conflictHash)
	c.setBuf <- &item{

Please add a comment here as explained in the last review.

Signed-off-by: balaji <balaji@dgraph.io>
Copy link
Contributor Author

@poonai poonai 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: 2 of 3 files reviewed, 1 unresolved discussion (waiting on @jarifibrahim, @karlmcguire, and @manishrjain)


cache.go, line 220 at r2 (raw file):

Previously, manishrjain (Manish R Jain) wrote…

Please add a comment here as explained in the last review.

Done.

Copy link
Contributor

@jarifibrahim jarifibrahim left a comment

Choose a reason for hiding this comment

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

Please undo the change in the test or add a new one instead :)

Reviewed 2 of 3 files at r1, 1 of 1 files at r3.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @balajijinnah, @karlmcguire, and @manishrjain)


cache.go, line 220 at r2 (raw file):

Previously, balajijinnah (balaji) wrote…

Done.

Nit: Grammatical error, (use Grammarly, it helps)

If we've set an item, it would be applied slightly later. So it is important that we push the same item to `setBuf` with the deletion flag. This ensures that if a set is followed by a delete, it will be applied in the correct order.

cache_test.go, line 174 at r3 (raw file):

	}
	key, conflict = z.KeyToHash(1)
	c.setBuf <- &item{

Why was this removed? This seems to be testing item deletion.

If this has to be removed, please add a new test for delete. The existing test for delete is not as comprehensive as this one.

Signed-off-by: balaji jinnah <rbalajis25@gmail.com>
Copy link
Contributor Author

@poonai poonai 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: 1 of 3 files reviewed, 2 unresolved discussions (waiting on @jarifibrahim, @karlmcguire, and @manishrjain)


cache_test.go, line 174 at r3 (raw file):

Previously, jarifibrahim (Ibrahim Jarif) wrote…

Why was this removed? This seems to be testing item deletion.

If this has to be removed, please add a new test for delete. The existing test for delete is not as comprehensive as this one.

Done.

Copy link
Contributor

@jarifibrahim jarifibrahim left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 2 of 2 files at r4.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @karlmcguire and @manishrjain)

@poonai poonai merged commit adb35f0 into master Jan 15, 2020
@martinmr martinmr deleted the balaji/del branch February 24, 2020 20:10
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