Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Fix unknown exception caused by thread safety issue #2033

Merged
merged 4 commits into from
Jan 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,18 @@ private static class PendingProduceCallback implements Runnable {
final CompletableFuture<Map<TopicPartition, ProduceResponse.PartitionResponse>> completableFuture;
Map<TopicPartition, MemoryRecords> entriesPerPartition;
@Override
public void run() {
public synchronized void run() {
topicPartitionNum.set(0);
if (completableFuture.isDone()) {
// It may be triggered again in DelayedProduceAndFetch
return;
}
// add the topicPartition with timeout error if it's not existed in responseMap
entriesPerPartition.keySet().forEach(topicPartition -> {
if (!responseMap.containsKey(topicPartition)) {
ProduceResponse.PartitionResponse response = responseMap.putIfAbsent(topicPartition,
new ProduceResponse.PartitionResponse(Errors.REQUEST_TIMED_OUT));
if (response == null) {
log.error("Adding dummy REQUEST_TIMED_OUT to produce response for {}", topicPartition);
responseMap.put(topicPartition, new ProduceResponse.PartitionResponse(Errors.REQUEST_TIMED_OUT));
}
});
if (log.isDebugEnabled()) {
Expand Down
Loading