Skip to content

Commit ddab943

Browse files
KAFKA-18265: Move persister call outside of the lock (3/N) (#20316)
Minor PR to move persister call outside of the lock. The lock is not required while making the persister call. Reviewers: Manikumar Reddy <[email protected]>, Abhinav Dixit <[email protected]>
1 parent f12a9d8 commit ddab943

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

core/src/main/java/kafka/server/share/SharePartition.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2424,22 +2424,22 @@ && checkForStartOffsetWithinBatch(inFlightBatch.firstOffset(), inFlightBatch.las
24242424
releaseAcquisitionLockOnTimeoutForPerOffsetBatch(inFlightBatch, stateBatches, memberId, firstOffset, lastOffset);
24252425
}
24262426
}
2427-
2428-
if (!stateBatches.isEmpty()) {
2429-
writeShareGroupState(stateBatches).whenComplete((result, exception) -> {
2430-
if (exception != null) {
2431-
log.debug("Failed to write the share group state on acquisition lock timeout for share partition: {}-{} memberId: {}",
2432-
groupId, topicIdPartition, memberId, exception);
2433-
}
2434-
// Even if write share group state RPC call fails, we will still go ahead with the state transition.
2435-
// Update the cached state and start and end offsets after releasing the acquisition lock on timeout.
2436-
maybeUpdateCachedStateAndOffsets();
2437-
});
2438-
}
24392427
} finally {
24402428
lock.writeLock().unlock();
24412429
}
24422430

2431+
if (!stateBatches.isEmpty()) {
2432+
writeShareGroupState(stateBatches).whenComplete((result, exception) -> {
2433+
if (exception != null) {
2434+
log.debug("Failed to write the share group state on acquisition lock timeout for share partition: {}-{} memberId: {}",
2435+
groupId, topicIdPartition, memberId, exception);
2436+
}
2437+
// Even if write share group state RPC call fails, we will still go ahead with the state transition.
2438+
// Update the cached state and start and end offsets after releasing the acquisition lock on timeout.
2439+
maybeUpdateCachedStateAndOffsets();
2440+
});
2441+
}
2442+
24432443
// If we have an acquisition lock timeout for a share-partition, then we should check if
24442444
// there is a pending share fetch request for the share-partition and complete it.
24452445
// Skip null check for stateBatches, it should always be initialized if reached here.

0 commit comments

Comments
 (0)