squah-confluent commented on code in PR #24146:
URL: https://github.com/apache/kafka/pull/24146#discussion_r4516807485


##########
server-common/src/main/java/org/apache/kafka/timeline/SnapshottableHashTable.java:
##########
@@ -128,6 +128,7 @@ public void mergeFrom(long epoch, Delta source) {
                             deltaTable.baseAddOrReplace(element);
                         }
                     }
+                    list.clear();

Review Comment:
   I suppose this is really difficult to test.
   



##########
server-common/src/main/java/org/apache/kafka/timeline/SnapshottableHashTable.java:
##########
@@ -429,6 +430,9 @@ public void executeRevert(long targetEpoch, Delta delta) {
                 }
                 out.clear();
             }
+            // The elements of the tier are back in the current state. Drop 
them from the tier
+            // so that iterating over the snapshot does not return them twice.
+            tier.deltaTable = null;

Review Comment:
   I would prefer if we fix this at the level of the snapshot system.
   
   The `Delta`s contain instructions for reverting to the start of the epoch. 
They should only be used once. It's a bug that the snapshotting system leaves 
used `Delta`s in place after a revert. The other `Timeline` containers are 
unaffected because they happen to have idempotent `Delta`s.



##########
server-common/src/main/java/org/apache/kafka/timeline/SnapshottableHashTable.java:
##########
@@ -128,6 +128,7 @@ public void mergeFrom(long epoch, Delta source) {
                             deltaTable.baseAddOrReplace(element);
                         }
                     }
+                    list.clear();

Review Comment:
   > A related issue affects SnapshotRegistry.deleteSnapshot(long), which no
   production code calls: HashTier.mergeFrom never clears the list of the
   slot it unpacks, so the merged tier can grow larger than the current
   table, and the iterator then skips elements.
   
   PR description:
   * Doesn't this bug also impact regular reverts?
   * The way the merged tier can grow larger than the current table is a bit 
subtle and could use more explanation (replacing an existing entry in the delta 
table can trigger expansion even though the number of entries doesn't grow)



##########
server-common/src/main/java/org/apache/kafka/timeline/SnapshottableHashTable.java:
##########
@@ -128,6 +128,7 @@ public void mergeFrom(long epoch, Delta source) {
                             deltaTable.baseAddOrReplace(element);
                         }
                     }
+                    list.clear();

Review Comment:
   The `deltaTable.capacity <= currentTable.capacity` invariant also seems 
pretty easy to break by accident. I wonder if there is a good way to enforce 
it, such as specifying a max capacity when creating the delta table (the delta 
table for epoch N cannot contain more entries than the current table at the 
start of the epoch, so I think it's okay to freeze the max capacity to match 
the current table at the start of the epoch). That kind of change probably 
belongs in a separate PR.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to