Hello :wave: Noob question :pray: : We have a stat...
# troubleshooting
a
Hello πŸ‘‹ Noob question πŸ™ : We have a stateless app that reads from a kafka topic and makes async http calls to a REST Api that is relatively slow (around ~5s in response time). The app seems to be checkpointing and producing records, but no offsets are being committed to kafka, especially when it has a lot to process. β€’
enable.auto.commit
is set to
false
β€’
async.capacity
is set to 10 β€’ 2 TMs, parallelism is 6. -> If we reset the offsets to latest and with low traffic, it seems to work fine. What could be the reason behind Flink being unable to commit offsets to Kafka in this scenario?
a
Hi @TRL Tech Thank you for the link. I checked that part earlier, The app manages to complete checkpoints, and even so, offsets are not committed
t
It should https://github.com/apache/flink-connector-kafka/blob/0fed445e80149fb44c51d54054411[…]ache/flink/connector/kafka/source/reader/KafkaSourceReader.java Does your logs print
Offset commit on checkpoint is disabled
? Try settings the property
commit.offsets.on.checkpoint
to
true
(Although that should be the default)
a
No occurrences of that log. What I can't understand is: It was unable to commit offsets when we started it from the earliest offsets ( a lot to handle), and when we restarted it it couldn't restore a checkpoint
Copy code
No checkpoint found during restore.
It did process records as we have seen them in the sink. But when we reset the offsets to latest where there isn't a lot of traffic, it managed to commit the offsets
Could a high amount of slow AsyncIO calls be interfering?
t
Yes I believe so. Try reading this. There's also ways to address the issue
❀️ 1
But you say that it was able to complete the checkpoint when running from
earliest
? If it completes a checkpoint, the offset should be committed πŸ€·β€β™‚οΈ
a
If it completes a checkpoint, the offset should be committed πŸ€·β€β™‚οΈ
That's the weird part. We reset the offsets to
earliest
, and started the app. It processed records (we have seen them in the sink topic and in DB.
Then we noticed that offsets were not being committed
Copy code
Consumer group 'flink-ticket-auto-qa' has no active members.

GROUP                TOPIC                                             PARTITION  CURRENT-OFFSET  LOG-END-OFFSET  LAG   
flink-ticket-auto-qa auto-qa.commands.score-ticket                     1          0               11015           11015 
flink-ticket-auto-qa auto-qa.commands.score-ticket                     0          0               10885           10885 
flink-ticket-auto-qa auto-qa.commands.score-ticket                     3          0               10973           10973 
flink-ticket-auto-qa auto-qa.commands.score-ticket                     2          0               10891           10891
So we restarted the app as we suspected broker info not being reliable. But when it restarted, it didn't find the previous checkpoints
Screenshot 2024-10-31 at 10.25.06.png,Screenshot 2024-10-31 at 10.25.53.png
And starts checkpointing again from checkpoint 1 and data is reprocessed again. We noticed the duplicates downstream
t
Ok. If you define the offset strategy to earliest it never used the committed offset from kafka (docs). It only starts from the checkpoint committed offset which is not stored in kafka but stored by flink in the place you defined the checkpoint storage. It seems that it cannot locate that checkpoint judging by your screen shots. You need to have checkpoints stored in a persistent storage somewhere in order for them to survive an application restart. If you use the
.setStartingOffsets(OffsetsInitializer.committedOffsets())
it will use the offset committed to kafka if it cannot find the offset in the latest checkpoint.
a
Yes, we have that mechanism defined. We use GCS to store checkpoints and default to
earliest
as a
Copy code
OffsetResetStrategy offsetResetStrategy = parameterTool.get("kafka.offsetResetStrategy", "earliest").equalsIgnoreCase("latest") 
        ? OffsetResetStrategy.LATEST 
        : OffsetResetStrategy.EARLIEST;

    KafkaDeserializationSchema<T> kafkaDeserializationSchema = ...;

    KafkaSourceBuilder<T> eventKafkaSourceBuilder =
        KafkaSource.<T>builder()
            .setBootstrapServers(bootstrapServers)
            .setTopics(Arrays.asList(topicName.split(",")))
            .setGroupId(consumerGroup)
            .setStartingOffsets(OffsetsInitializer.committedOffsets(offsetResetStrategy)) // <---- Here is where it get the strategy
            .setDeserializer(KafkaRecordDeserializationSchema.of(kafkaDeserializationSchema));
checkpints folder in GCS only contained the
_metadata
file, and I am assuming that it is the case for stateless apps
t
A stateless application does not mean it won't store anything in the checkpoints. It simply means you don't save any state in your operators. The checkpoint should still contain something. Look at https://nightlies.apache.org/flink/flink-docs-release-1.20/docs/ops/state/checkpoints/#checkpoints. See if you maybe store it on the heap, meaning it would be lost when restarting.