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

Critical bug in compare-and-set* #15

Open
kwisath opened this issue Nov 25, 2023 · 0 comments
Open

Critical bug in compare-and-set* #15

kwisath opened this issue Nov 25, 2023 · 0 comments

Comments

@kwisath
Copy link

kwisath commented Nov 25, 2023

The compare-and-set* function contains a bug that is hard to spot and can result in a failed compare and set to be compared as successful while it is not.

The problem is with this check

(some? (r/wcar conn
                   (r/multi)
                   (r/set k {:data newval})
                   (r/exec)))

The Carmine return for wcar will always be a vector ["OK" "QUEUED" x] where x is the return of the exec, which in turn would be a vector with the return of all queued transaction operations. If all goes well x will be ["OK"] and if the transaction fails, would be nil. So when the transaction fails, the return is ["OK" "QUEUED" nil], which obviously returns true when passed to some? when it should return false.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant