[ https://issues.apache.org/jira/browse/GEODE-8840?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17266404#comment-17266404 ]
ASF GitHub Bot commented on GEODE-8840: --------------------------------------- jdeppe-pivotal commented on a change in pull request #5915: URL: https://github.com/apache/geode/pull/5915#discussion_r558653968 ########## File path: geode-redis/src/main/java/org/apache/geode/redis/internal/executor/key/RenameNxExecutor.java ########## @@ -0,0 +1,32 @@ +package org.apache.geode.redis.internal.executor.key; + +import static org.apache.geode.redis.internal.RedisConstants.ERROR_NO_SUCH_KEY; + +import java.util.List; + +import org.apache.geode.redis.internal.data.ByteArrayWrapper; +import org.apache.geode.redis.internal.executor.AbstractExecutor; +import org.apache.geode.redis.internal.executor.RedisResponse; +import org.apache.geode.redis.internal.netty.Command; +import org.apache.geode.redis.internal.netty.ExecutionHandlerContext; + +public class RenameNxExecutor extends AbstractExecutor { + @Override + public RedisResponse executeCommand(Command command, ExecutionHandlerContext context) { + + List<ByteArrayWrapper> commandElems = command.getProcessedCommandWrappers(); + ByteArrayWrapper key = command.getKey(); + ByteArrayWrapper newKey = commandElems.get(2); + RedisKeyCommands redisKeyCommands = getRedisKeyCommands(context); + + if (redisKeyCommands.exists(newKey)) { + return RedisResponse.integer(0); + } + + if (!redisKeyCommands.rename(key, newKey)) { Review comment: I think this will need a bit more work since there is a race condition here. Consider the case when two separate requests (on different servers) perform the check above and each request makes it through the check... Before digging into that, I'd suggest writing a concurrent test to highlight the problem here. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > implement redis RENAMENX command > -------------------------------- > > Key: GEODE-8840 > URL: https://issues.apache.org/jira/browse/GEODE-8840 > Project: Geode > Issue Type: Improvement > Components: redis > Reporter: John Hutchison > Priority: Major > Labels: pull-request-available > -- This message was sent by Atlassian Jira (v8.3.4#803005)