-
Notifications
You must be signed in to change notification settings - Fork 9.8k
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
fix Compare and swap returns incorrect cause #614
Conversation
@@ -322,10 +322,15 @@ func (n *node) UpdateTTL(expireTime time.Time) { | |||
} | |||
|
|||
func (n *node) Compare(prevValue string, prevIndex uint64) bool { |
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.
@metaflow Can you change this to return (ok bool, which int)
.
So you do not need to compare it again in getCompareFailCause
.
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.
@xiangli-cmu sure
for for both match which = 0
only index match - 1
only value match - 2
both mismatch - 3
sounds good?
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.
Can you add const variables for these const numbers? Like
const (
match = 0
indexNotMatch = 1
valueNotMatch = 2
NoMatch =3
)
I think we can just use positive number. 1 for index not match, 2 for value not match, and 3 for neither of them.
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.
@xiangli-cmu one more question - it should be added as exported const in header of this file, shouldn't it?
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.
@metaflow Oh. Yes. since the function is exported.
@metaflow Thank you for working on this! |
@xiangli-cmu I have changed result of |
lgtm |
Can you squash these commits? |
specifically when both prevIndex and prevValue are provided
@xiangli-cmu @philips done, fixed commit message as well |
I will update API docs in another PR if you don't mind (I already have #610 not merged yet :) so I can add this there) |
lgtm, merging. |
fix Compare and swap returns incorrect cause
fix for issue #611
Note that compare-and-delete cause changed too.
I worry about modifications in v1 tests while v1 API is frozen.
Thank you!