Open mpkorstanje opened 7 months ago
It is tough to provide a known exact fix for this without a definite reproducer (and I have not successfully been able to reproduce it in our test suite so far either), but I do think we should at least make some changes in ConsumerStateBatch
to code a little more defensively. currentOffsets
in particular is marked as @Nullable
in most of the methods where it is passed around, and yet we don't seem to be doing anything to verify that is it not null when we should be.
My best guess is that it is a timing problem in the "slow" CI machine and the consumer hasn't yet been assigned a partition by Kafka (or it could be in the midst of being reassigned), and we need to account for that state.
My best guess is that it is a timing problem in the "slow" CI machine and the consumer hasn't yet been assigned a partition by Kafka (or it could be in the midst of being reassigned), and we need to account for that state.
I would concur with that guess. The current workaround is to run a passing test case before testing the failure, giving Kafka the time to assign partitions and finish balancing.
Defensive programming would make sense. I do think the @NonNull
annotation are a red herring though.
For this specific exception, it is not currentOffsets
that is null, but rather currentOffsets.get(tp)
returns null.
Expected Behavior
Given a Kafka listener with retry enabled, when an exception is thrown from the listener, it should be retried.
Actual Behaviour
Steps To Reproduce
I can only reproduce this problem on a rather slow CI machine. I've tried to reproduce this locally, with no success. If anything I wouldn't expect an NPE and suspect that this may be due to a race condition. At a glance it looks like the
partitions
andcurrentOffsets
are collected from Kafka at different times and may be subject to change.Environment Information
Ci uses the following docker images:
maven:3.8.6-eclipse-temurin-17
confluentinc/cp-zookeeper:7.3.1
confluentinc/cp-kafka:7.3.1
Example Application
No response
Version
micronaut-platform:4.3.4
micronaut-kafka:5.3.0