Roiocam commented on code in PR #156:
URL: 
https://github.com/apache/incubator-pekko-persistence-jdbc/pull/156#discussion_r1531450564


##########
core/src/test/scala/org/apache/pekko/persistence/jdbc/state/scaladsl/JdbcDurableStateSpec.scala:
##########
@@ -113,6 +113,45 @@ abstract class JdbcDurableStateSpec(config: Config, 
schemaType: SchemaType) exte
         }
       }
     }
+    "delete old object revision but not latest" in {
+      whenReady {
+        for {
+
+          n <- stateStoreString.upsertObject("p987", 1, "a valid string", 
"t123")
+          _ = n shouldBe pekko.Done
+          g <- stateStoreString.getObject("p987")
+          _ = g.value shouldBe Some("a valid string")
+          u <- stateStoreString.upsertObject("p987", 2, "updated valid 
string", "t123")
+          _ = u shouldBe pekko.Done
+          d <- stateStoreString.deleteObject("p987", 1)
+          _ = d shouldBe pekko.Done
+          h <- stateStoreString.getObject("p987")
+
+        } yield h
+      } { v =>
+        v.value shouldBe Some("updated valid string")
+      }
+    }
+    "delete latest object revision but not older one" in {
+      whenReady {
+        for {
+
+          n <- stateStoreString.upsertObject("p9876", 1, "a valid string", 
"t123")
+          _ = n shouldBe pekko.Done
+          g <- stateStoreString.getObject("p9876")
+          _ = g.value shouldBe Some("a valid string")
+          u <- stateStoreString.upsertObject("p9876", 2, "updated valid 
string", "t123")
+          _ = u shouldBe pekko.Done
+          d <- stateStoreString.deleteObject("p9876", 2)
+          _ = d shouldBe pekko.Done
+          h <- stateStoreString.getObject("p9876")
+
+        } yield h
+      } { v =>
+        // TODO current behavior is that deleting the latest revision means 
getObject returns None (not an older revision)
+        v.value shouldBe None

Review Comment:
   > I don't understand why the API has deleteObject(persistenceId, revision) 
if it does not keep all the revisions.
   
   I think it is for safety reasons. When a split-brain occurs, nodes in the 
older version of the partition are not allowed to try to delete the data with 
the newer version.
   
   For example, we have nodes: [A, B, C, D], and the split-brain splits them 
into two network partitions of [A,C] [B,D]. 
   
   Node A updated the revision of persistence Actor X001 from 10 to 11, while 
Node B has Sharding X001 is still version 10, so it is not allowed to delete 
X001 from B, but it is okay to delete X001 from A.



-- 
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-unsubscr...@pekko.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@pekko.apache.org
For additional commands, e-mail: notifications-h...@pekko.apache.org

Reply via email to