diff --git a/kafka-impl/src/main/java/io/streamnative/pulsar/handlers/kop/storage/PartitionLog.java b/kafka-impl/src/main/java/io/streamnative/pulsar/handlers/kop/storage/PartitionLog.java index c49e303f5c..71f46ea5b4 100644 --- a/kafka-impl/src/main/java/io/streamnative/pulsar/handlers/kop/storage/PartitionLog.java +++ b/kafka-impl/src/main/java/io/streamnative/pulsar/handlers/kop/storage/PartitionLog.java @@ -884,8 +884,10 @@ public void readEntriesFailed(ManagedLedgerException exception, Object ctx) { if (exception instanceof ManagedLedgerException.ManagedLedgerFencedException) { invalidateCacheOnTopic.accept(fullPartitionName); } - messageReadStats.registerFailedEvent( - MathUtils.elapsedNanos(startReadingMessagesNanos), TimeUnit.NANOSECONDS); + long failedLatencyNanos = MathUtils.elapsedNanos(startReadingMessagesNanos); + eventExecutor.execute(() -> { + messageReadStats.registerFailedEvent(failedLatencyNanos, TimeUnit.NANOSECONDS); + }); readFuture.completeExceptionally(exception); } }, null, PositionImpl.LATEST);