Skip to content

Commit f94f7ca

Browse files
Addressed Jun's round 3 review comments - part 2
1 parent 7c46f4c commit f94f7ca

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,17 @@ public boolean tryComplete() {
331331
releasePartitionLocks(topicPartitionData.keySet());
332332
partitionsAcquired.clear();
333333
localPartitionsAlreadyFetched.clear();
334+
return forceComplete();
335+
} else {
336+
boolean completedByMe = forceComplete();
337+
// If invocation of forceComplete is not successful, then that means the request is already completed
338+
// hence release the acquired locks. This can occur in case of remote storage fetch if there is a thread that
339+
// completes the operation (due to expiration) right before a different thread is about to enter tryComplete.
340+
if (!completedByMe) {
341+
releasePartitionLocks(partitionsAcquired.keySet());
342+
}
343+
return completedByMe;
334344
}
335-
return forceComplete();
336345
}
337346
}
338347

0 commit comments

Comments
 (0)