adixitconfluent commented on code in PR #20124:
URL: https://github.com/apache/kafka/pull/20124#discussion_r2195524099


##########
core/src/main/java/kafka/server/share/SharePartition.java:
##########
@@ -3103,25 +3112,37 @@ private int updatedDeliveryCount(DeliveryCountOps ops) {
             };
         }
 
-        private void archive(String newMemberId) {
+        // Visible for testing.
+        synchronized void archive(String newMemberId) {
+            if (rollbackState != null) {
+                isMarkedArchived = true;
+            }
             state = RecordState.ARCHIVED;
             memberId = newMemberId;
         }
 
-        private InFlightState startStateTransition(RecordState newState, 
DeliveryCountOps ops, int maxDeliveryCount, String newMemberId) {
-            rollbackState = new InFlightState(state, deliveryCount, memberId, 
acquisitionLockTimeoutTask);
-            return tryUpdateState(newState, ops, maxDeliveryCount, 
newMemberId);
+        // Visible for testing
+        synchronized InFlightState startStateTransition(RecordState newState, 
DeliveryCountOps ops, int maxDeliveryCount, String newMemberId) {
+            InFlightState currentState = new InFlightState(state, 
deliveryCount, memberId, acquisitionLockTimeoutTask);
+            InFlightState updatedState = tryUpdateState(newState, ops, 
maxDeliveryCount, newMemberId);
+            if (updatedState != null) {
+                rollbackState = currentState;
+            }
+            return updatedState;
         }
 
-        private void completeStateTransition(boolean commit) {
-            if (commit) {
+        // Visible for testing
+        synchronized void completeStateTransition(boolean commit) {
+            if (commit || isMarkedArchived) {

Review Comment:
   I don't think so, in both the conditions the record has moved to either 
`AVAILABLE/ACKNOWLEDGED/ARCHIVED` state. It won't be in ACQUIRED state, so I 
don't think we need to run the acquisition lock timeout here again.



-- 
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: jira-unsubscr...@kafka.apache.org

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

Reply via email to