You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@geode.apache.org by GitBox <gi...@apache.org> on 2022/02/02 17:15:19 UTC

[GitHub] [geode] ezoerner commented on a change in pull request #7328: GEODE-9994 Make Redis RENAME atomic

ezoerner commented on a change in pull request #7328:
URL: https://github.com/apache/geode/pull/7328#discussion_r797837970



##########
File path: geode-for-redis/src/distributedTest/java/org/apache/geode/redis/internal/commands/executor/key/RenameDUnitTest.java
##########
@@ -239,24 +298,33 @@ public void givenBucketsMoveDuringRename_thenDataIsNotLost() throws Exception {
     future3.get();
   }
 
-  private void renamePerformAndVerify(int index, int minimumIterations, String hashtag,
-      AtomicBoolean isRunning) {
-    String baseKey = "{" + hashtag + "}-key-" + index;
+  private void renamePerformAndVerify(final int index, final int minimumIterations,
+      final String hashtag, final AtomicBoolean isRunning, final boolean continueOnError) {
+    final String baseKey = "{" + hashtag + "}-key-" + index;
     jedisCluster.set(baseKey + "-0", "value");
     int iterationCount = 0;
 
     while (iterationCount < minimumIterations || isRunning.get()) {
-      String oldKey = baseKey + "-" + iterationCount;
-      String newKey = baseKey + "-" + (iterationCount + 1);
+      final String oldKey = baseKey + "-" + iterationCount;
+      final String newKey = baseKey + "-" + (iterationCount + 1);
+
+      // it's possible previous rename failed, so make sure oldKey exists
+      jedisCluster.setnx(oldKey, "value");
+
       try {
         jedisCluster.rename(oldKey, newKey);
-      } catch (Exception ex) {
-        isRunning.set(false);
-        throw new RuntimeException("Exception performing RENAME " + oldKey + " " + newKey, ex);
+      } catch (final Exception ex) {
+        if (continueOnError) {
+          logger.error("Exception performing RENAME " + oldKey + " " + newKey, ex);

Review comment:
       ah, didn't know that, I'll change that




-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@geode.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org