keith-turner commented on code in PR #4204:
URL: https://github.com/apache/accumulo/pull/4204#discussion_r1481529548


##########
core/src/main/java/org/apache/accumulo/core/fate/AbstractFateStore.java:
##########
@@ -239,12 +254,46 @@ public int getDeferredCount() {
     }
   }
 
+  @Override
+  public FateId create(FateKey fateKey) {
+    FateId fateId = fateIdGenerator.fromTypeAndKey(getInstanceType(), fateKey);
+    Pair<TStatus,Optional<FateKey>> statusAndKey = getStatusAndKey(fateId);
+    TStatus status = statusAndKey.getFirst();
+    Optional<FateKey> tFateKey = statusAndKey.getSecond();
+
+    // Case 1: Status of UNKNOWN means doesn't exist, so we can create
+    if (status == TStatus.UNKNOWN) {
+      create(fateId, fateKey);
+      // Case 2: Status is NEW so this is unseeded, we can return and allow 
the calling code
+      // to reserve/seed as long as the existing key is the same and not 
different as that would
+      // mean a collision
+    } else if (status == TStatus.NEW) {
+      Preconditions.checkState(tFateKey.isPresent(), "Tx key column is 
missing");

Review Comment:
   I don't think there is a test for a collision between a random fate id and 
hash derived fate id.  Im 99.9% sure this code works, but was wondering if 
creating a test for that is worthwhile for detecting regressions.



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

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

Reply via email to