-
Notifications
You must be signed in to change notification settings - Fork 612
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
ISPN-14654 MSETNX #10944
ISPN-14654 MSETNX #10944
Conversation
Please add a row to the table in |
32123cf
to
a253dda
Compare
server/resp/src/main/java/org/infinispan/server/resp/commands/string/MSETNX.java
Show resolved
Hide resolved
server/resp/src/main/java/org/infinispan/server/resp/commands/string/MSETNX.java
Show resolved
Hide resolved
server/resp/src/main/java/org/infinispan/server/resp/commands/string/MSETNX.java
Show resolved
Hide resolved
entries.put(arguments.get(i), arguments.get(++i)); | ||
} | ||
// Change to loop? | ||
var existingEntries = handler.cache().getAll(entries.keySet()); |
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.
With the current implementation:
- entries = getAll(keys)
- if entries.size()==0 then putAll(newEntries)
if an concurrent put(conflictingEntry) operation happens btween 1 and 2, there's no way to keep the semantic of the operation, I mean:
- order (msetnx then set) must result in conflictEntry to be present, but it has been actually overwritten
- order (set then msetnx) must result in msetnx not be executed since concEntry is present.
Replacing putAll with a loop of putIfAbsent results in a consistent story (msetnx then set), the cost is to replace an atomic operation with a loop.
I can't see any better solution without involving transactions.
any preference/though?
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.
I don't think there is any way to do this without transactions or some type of 2 step operation when in a cluster. We can do simpler things with a single node, but in a cluster we really need something like a distributed transaction, a new command won't remedy that sadly.
Rebase please |
rebased |
dfc15bf
to
4843f6c
Compare
@rigazilla needs rebase. @karesti @jabolina can you review? |
4843f6c
to
cfd2261
Compare
cfd2261
to
de14399
Compare
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.
Seems fine to me, if anyone else wants to double check.
Thanks, @rigazilla! |
https://issues.redhat.com/browse/ISPN-14654