You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by Dongwon Kim <ea...@gmail.com> on 2021/11/07 09:40:27 UTC
how to expose the current in-flight async i/o requests as metrics?
Hi community,
While using Flink's async i/o for interacting with an external system, I
got the following exception:
2021-11-06 10:38:35,270 INFO
org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] -
Triggering checkpoint 54 (type=CHECKPOINT) @ 1636162715262 for job
f168a44ea33198cd71783824d49f9554.
2021-11-06 10:38:47,031 INFO
org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] -
Completed checkpoint 54 for job f168a44ea33198cd71783824d49f9554
(11930992707 bytes, checkpointDuration=11722 ms, finalizationTime=47
ms).
2021-11-06 10:58:35,270 INFO
org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] -
Triggering checkpoint 55 (type=CHECKPOINT) @ 1636163915262 for job
f168a44ea33198cd71783824d49f9554.
2021-11-06 11:08:35,271 INFO
org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] -
Checkpoint 55 of job f168a44ea33198cd71783824d49f9554 expired before
completing.
2021-11-06 11:08:35,287 INFO
org.apache.flink.runtime.jobmaster.JobMaster [] -
Trying to recover from a global failure.
- FYI, I'm using 1.14.0 and enabled unaligned checkpointing and buffer
debloating
- the 55th ckpt failed to complete within 10 mins (which is the value of
execution.checkpointing.timeout)
- the below graph shows that backpressure skyrocketed around the time the
55th ckpt began
[image: image.png]
What I suspect is the capacity of the asynchronous operation because
limiting the value can cause back-pressure once the capacity is exhausted
[1].
Although I could increase the value, I want to monitor the current
in-flight async i/o requests like the above back-pressure graph on Grafana.
[2] does not introduce any system metric specific to async i/o.
Best,
Dongwon
[1]
https://ci.apache.org/projects/flink/flink-docs-master/docs/dev/datastream/operators/asyncio/#async-io-api
[2]
https://ci.apache.org/projects/flink/flink-docs-master/docs/ops/metrics/#system-metrics
Re: how to expose the current in-flight async i/o requests as metrics?
Posted by Dongwon Kim <ea...@gmail.com>.
Hi Fabian,
Can you maybe share more about the setup and how you use the AsyncFunction
> with
> the Kafka client?
Oops, I didn't mention in the reply to David that the kafka producer has
nothing to do with the AsyncFunction!
I interact with Redis and a Spring boot app. in the AsyncFunction, not
Kafka.
My pipeline looks like "KafkaSource -> AsyncFunction -> Window ->
(KafkaSink1, KafkaSink2)" and the kafka producer is the last one.
As David already pointed out it could be indeed a Kafka bug but it could
> also
> mean that your defined async function leaks direct memory by not freeing
> some
> resources.
The problem seems to be the KafkaSink2 which I recently added to the
pipeline in order to write large records (~10MB) for a debugging purpose.
I just launched the pipeline without KafkaSink2 to see whether or not my
conjecture is right or wrong.
If so, I'd rather give more direct memory to each task manager to avoid
this problem.
We can definitely improve the metrics for the AsyncFunction and expose the
> current queue size as a followup.
Really looking forward to it. I spent many hours debugging AsyncFunction
without metrics. It would be great to have how many records are timed out
as a metric as well.
Thanks,
Dongwon
On Tue, Nov 9, 2021 at 7:55 PM Fabian Paul <fa...@ververica.com> wrote:
> Hi Dongwan,
>
> Can you maybe share more about the setup and how you use the AsyncFunction
> with
> the Kafka client?
>
> As David already pointed out it could be indeed a Kafka bug but it could
> also
> mean that your defined async function leaks direct memory by not freeing
> some
> resources.
>
> We can definitely improve the metrics for the AsyncFunction and expose the
> current queue size as a followup.
>
> Best,
> Fabian
Re: how to expose the current in-flight async i/o requests as metrics?
Posted by Chesnay Schepler <ch...@apache.org>.
No. But I have seen direct memory issues in our tests during my
experiments with Java 17.
On 24/11/2021 09:40, Arvid Heise wrote:
> @Chesnay Schepler <ma...@apache.org>
> , have you heard of any Java 11-specific issues with direct memory?
>
> At this point, I'm actually excluding a bug in KafkaProducer and
> KafkaSink. It may either be a bug in Kafka or Netty on Java 11.
>
> On Fri, Nov 19, 2021 at 10:50 AM Dongwon Kim <ea...@gmail.com>
> wrote:
>
> Hi,
>
> For the last few days, I've tried the following, both of which
> seem to resolve the issue:
>
> 1. setting jdk.nio.maxCachedBufferSize for TMs on Java 11
> image.png
> I found some articles [1], [2] and an old post of Flink user ML
> [3], which said that a per-thread cache of direct memory can cause
> such an OOM problem. By setting a
> jdk.nio.maxCachedBufferSize property, I can observe the direct
> memory usage is no longer indefinitely increasing.
>
> 2. downgrade the Java version from 11 to 8 (even without setting
> jdk.nio.maxCachedBufferSize)
> image.png
> I don't know why Java 8 doesn't have any problems and Java 11 does.
>
> The below is with Java 11 without setting jdk.nio.maxCachedBufferSize:
> image.png
>
> Best,
>
> Dongwon
>
> [1] https://www.evanjones.ca/java-bytebuffer-leak.html
> [2]
> https://dzone.com/articles/troubleshooting-problems-with-native-off-heap-memo
> [3]
> http://mail-archives.apache.org/mod_mbox/flink-user/201712.mbox/%3CCANq+ctpiyNw1ueybQUgZJk4ciSyvfAmNq_1TA6NbnFxbfF+XHw@mail.gmail.com%3E
>
>
> On Wed, Nov 17, 2021 at 2:03 PM Dongwon Kim
> <ea...@gmail.com> wrote:
>
> Hi Arvid,
>
> Unfortunately, even with Kafka 2.8.1 on Flink-1.14.0 for Scala
> 2.12,
> the direct memory usage had been ever increasing:
> image.png
>
> I double-checked that the newer version of Kafka client is
> used via TM logs:
>
> 2021-11-15 20:20:22,148 INFO
> org.apache.flink.yarn.YarnTaskExecutorRunner [] -
> --------------------------------------------------------------------------------
> 2021-11-15 20:20:22,156 INFO
> org.apache.flink.yarn.YarnTaskExecutorRunner [] - Starting
> YARN TaskExecutor runner (Version: 1.14.0, Scala: 2.12,
> Rev:460b386, Date:2021-09-22T08:39:40+02:00)
>
> // ... 2021-11-15 20:20:29,761 INFO
> org.apache.kafka.common.utils.AppInfoParser [] - Kafka
> version: 2.8.1 2021-11-15 20:20:29,761 INFO
> org.apache.kafka.common.utils.AppInfoParser [] - Kafka
> commitId: 839b886f9b732b15 2021-11-15 20:20:29,761 INFO
> org.apache.kafka.common.utils.AppInfoParser [] - Kafka
> startTimeMs: 1636975229757 2021-11-15 20:20:29,763 INFO
> org.apache.kafka.common.utils.AppInfoParser [] - Kafka
> version: 2.8.1 2021-11-15 20:20:29,763 INFO
> org.apache.kafka.common.utils.AppInfoParser [] - Kafka
> commitId: 839b886f9b732b15 2021-11-15 20:20:29,763 INFO
> org.apache.kafka.common.utils.AppInfoParser [] - Kafka
> startTimeMs: 1636975229758 2021-11-15 20:20:29,763 INFO
> org.apache.kafka.common.utils.AppInfoParser [] - Kafka
> version: 2.8.1 2021-11-15 20:20:29,764 INFO
> org.apache.kafka.common.utils.AppInfoParser [] - Kafka
> commitId: 839b886f9b732b15 2021-11-15 20:20:29,764 INFO
> org.apache.kafka.common.utils.AppInfoParser [] - Kafka
> startTimeMs: 1636975229758 2021-11-15 20:20:29,764 INFO
> org.apache.kafka.common.utils.AppInfoParser [] - Kafka
> version: 2.8.1 2021-11-15 20:20:29,764 INFO
> org.apache.kafka.common.utils.AppInfoParser [] - Kafka
> commitId: 839b886f9b732b15 2021-11-15 20:20:29,764 INFO
> org.apache.kafka.common.utils.AppInfoParser [] - Kafka
> startTimeMs: 1636975229758
>
> I attached the entire log message of a TM for the detailed
> information.
>
> While searching the web, I found that a guy from a Druid
> community told about
> Java 11 throwing OOM on Direct Buffer which didn't occur with
> Java 8 [1]. Few month ago,
> I upgraded Java from 8 to 11 when Flink 1.10 was announced
> [2]. I'm going to downgrade
> Java from 11 to 8 and see whether the ever increasing direct
> memory will be observed.
>
> [1]
> https://github.com/apache/druid/issues/5589#issuecomment-863112328
> [2]
> https://nightlies.apache.org/flink/flink-docs-release-1.10/release-notes/flink-1.10.html#java-11-support-flink-10725
> Best,
>
> Dongwon
>
> On Mon, Nov 15, 2021 at 4:57 PM Arvid Heise <ar...@apache.org>
> wrote:
>
> Thanks for the throughout investigation.
>
> Do you have the luxury to bump the Kafka client version?
> For that, you need to run on Scala 2_12 and then you could
> bump Kafka to 2.8.1. I would be interested if the issue
> still persists.
>
> On Sun, Nov 14, 2021 at 3:16 PM Dongwon Kim
> <ea...@gmail.com> wrote:
>
> Hi,
>
> 2. We suspect that the Kafka Sink is causing the
> problem. Can you try to run
> your pipeline with a simple DiscadingSink and see
> if the error keeps happening?
> Maybe another component in your pipeline allocates
> a lot of DirectMemory and
> only the FlinkKafkaProducer hides the problems
> because it is the first component
> hitting the threshold.
> Another option would be to test the new KafkaSink
> which was released with 1.14
> and should replace the FlinkKafkaProducer.
>
>
> I just launched a variant of the pipeline with
> DiscardingSink replacing all KakfaSink.
> As shown below, the direct memory usage does not go up
> with DiscardingSink as with KafkaSink,
> so I guess all the other components of the pipeline
> have nothing to do with direct memory leak.
> image.png
>
> One thing to note in the pipeline is that the size of
> output messages to Kafka is not that small.
> - 0.5 percentile : 33kb
> - 0.75 percentile : 95kb
> - 0.9 percentile : 243kb
> - 0.95 percentile : 391kb
> - 0.99 percentile : 810kb
> - 0.999 percentile : 1.1MB
> - 0.9999 percentile : 1.3MB
> - 0.99999 percentile : 1.6MB
> - 0.999999 percentile : 2.6MB
> - FYI, the stats are computed for output messages for
> the last 24 hours
>
> Anyway, I need to increase the parallelism of kafka
> sinks and the direct memory size for a while
> to cope with the OOM problem.
>
> Best,
>
> Dongwon
>
>
> On Sun, Nov 14, 2021 at 1:31 AM Dongwon Kim
> <ea...@gmail.com> wrote:
>
> Hi all,
>
> I also faced the same situation with the new
> KafkaSink. Below is the JVM directed memory over
> time and the attached is the JM log.
> image.png
>
> The new KafkaSink worked as I wanted: it caused JM
> to stop the whole pipeline and let me know
> which container had failed in JM log as follows:
>
> 2021-11-13 20:00:15,467 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Triggering checkpoint 77 (type=CHECKPOINT) @ 1636801215451 for job 63bcf8a835f5035370f60ca31f236cbf.
> 2021-11-13 20:00:29,840 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Completed checkpoint 77 for job 63bcf8a835f5035370f60ca31f236cbf (8694870137 bytes, checkpointDuration=14320 ms, finalizationTime=69 ms).
> 2021-11-13 20:00:29,844 INFO org.apache.flink.runtime.source.coordinator.SourceCoordinator [] - Marking checkpoint 77 as completed for source Source: kafka-source -> input-parser -> wm-gen -> navigps-filter.
> 2021-11-13 20:20:15,462 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Triggering checkpoint 78 (type=CHECKPOINT) @ 1636802415450 for job 63bcf8a835f5035370f60ca31f236cbf.
> 2021-11-13 20:20:27,725 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Completed checkpoint 78 for job 63bcf8a835f5035370f60ca31f236cbf (7422717674 bytes, checkpointDuration=12231 ms, finalizationTime=44 ms).
> 2021-11-13 20:20:27,728 INFO org.apache.flink.runtime.source.coordinator.SourceCoordinator [] - Marking checkpoint 78 as completed for source Source: kafka-source -> input-parser -> wm-gen -> navigps-filter.
> 2021-11-13 20:29:29,556 INFO org.apache.flink.runtime.executiongraph.ExecutionGraph [] - path-filter -> session-window -> (Sink late-data, session-filter -> enricher -> calculator -> (Sink kafka-sink, Sink kafka-sink-for-output-stats, filter-mm-failure -> Sink kafka-sink-for-mm-failure)) (10/64) (f75e736fa49e853d75b60428f30d5ca2) switched from RUNNING to FAILED on container_e141_1633577524620_0166_01_000002 @mobdata-flink-dn22.dakao.io <http://mobdata-flink-dn22.dakao.io> (dataPort=43902).
> org.apache.flink.util.FlinkRuntimeException: Failed to send data to Kafka null with FlinkKafkaInternalProducer{transactionalId='null', inTransaction=false, closed=false}
> at org.apache.flink.connector.kafka.sink.KafkaWriter$WriterCallback.throwException(KafkaWriter.java:402) ~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
> at org.apache.flink.connector.kafka.sink.KafkaWriter$WriterCallback.lambda$onCompletion$0(KafkaWriter.java:388) ~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
> at org.apache.flink.streaming.runtime.tasks.StreamTaskActionExecutor$1.runThrowing(StreamTaskActionExecutor.java:50) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
> at org.apache.flink.streaming.runtime.tasks.mailbox.Mail.run(Mail.java:90) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
> at org.apache.flink.streaming.runtime.tasks.mailbox.MailboxProcessor.processMailsNonBlocking(MailboxProcessor.java:353) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
> at org.apache.flink.streaming.runtime.tasks.mailbox.MailboxProcessor.processMail(MailboxProcessor.java:317) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
> at org.apache.flink.streaming.runtime.tasks.mailbox.MailboxProcessor.runMailboxLoop(MailboxProcessor.java:201) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
> at org.apache.flink.streaming.runtime.tasks.StreamTask.runMailboxLoop(StreamTask.java:809) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
> at org.apache.flink.streaming.runtime.tasks.StreamTask.invoke(StreamTask.java:761) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
> at org.apache.flink.runtime.taskmanager.Task.runWithSystemExitMonitoring(Task.java:958) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
> at org.apache.flink.runtime.taskmanager.Task.restoreAndInvoke(Task.java:937) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
> at org.apache.flink.runtime.taskmanager.Task.doRun(Task.java:766) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
> at org.apache.flink.runtime.taskmanager.Task.run(Task.java:575) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
> at java.lang.Thread.run(Thread.java:829) ~[?:?]
> Caused by: org.apache.kafka.common.errors.TimeoutException: Failed to allocate memory within the configured max blocking time 60000 ms.
>
>
> The other day I faced the similar exception
> (though it is not from Kafka producers):
>
> |2021-11-11 09:27:08,429 WARN
> org.apache.hadoop.hdfs.DataStreamer [] -
> DataStreamer Exception java.lang.OutOfMemoryError:
> Direct buffer memory at
> java.nio.Bits.reserveMemory(Bits.java:175) ~[?:?]
> at
> java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:118)
> ~[?:?] at
> java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:317)
> ~[?:?] at
> sun.nio.ch.Util.getTemporaryDirectBuffer(Util.java:242)
> ~[?:?] at sun.nio.ch.IOUtil.write(IOUtil.java:71)
> ~[?:?] at sun.nio.ch.IOUtil.write(IOUtil.java:50)
> ~[?:?] at
> sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:462)
> ~[?:?] at
> org.apache.hadoop.net.SocketOutputStream$Writer.performIO(SocketOutputStream.java:63)
> ~[hadoop-common-3.1.1.3.1.4.0-315.jar:?] at
> org.apache.hadoop.net.SocketIOWithTimeout.doIO(SocketIOWithTimeout.java:142)
> ~[hadoop-common-3.1.1.3.1.4.0-315.jar:?] at
> org.apache.hadoop.net.SocketOutputStream.write(SocketOutputStream.java:159)
> ~[hadoop-common-3.1.1.3.1.4.0-315.jar:?] at
> org.apache.hadoop.net.SocketOutputStream.write(SocketOutputStream.java:117)
> ~[hadoop-common-3.1.1.3.1.4.0-315.jar:?] at
> java.io.BufferedOutputStream.write(BufferedOutputStream.java:123)
> ~[?:?] at
> java.io.DataOutputStream.write(DataOutputStream.java:107)
> ~[?:?] at
> org.apache.hadoop.hdfs.DFSPacket.writeTo(DFSPacket.java:194)
> ~[hadoop-hdfs-client-3.1.1.3.1.4.0-315.jar:?] at
> org.apache.hadoop.hdfs.DataStreamer.run(DataStreamer.java:774)
> [hadoop-hdfs-client-3.1.1.3.1.4.0-315.jar:?]|
>
>
> Best,
>
> Dongwon
>
> On Wed, Nov 10, 2021 at 8:01 PM Dongwon Kim
> <ea...@gmail.com> wrote:
>
> Hi Fabian,
>
> 1. Since you already set up PromQL can you
> also share the JVM memory statics
> i.e. DirectMemory consumption over time? I
> would be interested to see whether
> the consumption is slowly increasing until
> the OOM happens or if it spikes
> only during the failing checkpoint.
>
>
> For all TMs:
> image.png
>
> For the TM:
> image.png
>
> 2. We suspect that the Kafka Sink is
> causing the problem. Can you try to run
> your pipeline with a simple DiscadingSink
> and see if the error keeps happening?
> Maybe another component in your pipeline
> allocates a lot of DirectMemory and
> only the FlinkKafkaProducer hides the
> problems because it is the first component
> hitting the threshold.
> Another option would be to test the new
> KafkaSink which was released with 1.14
> and should replace the FlinkKafkaProducer.
>
>
> I launched a variant of the same pipeline
> without the problematic sink 26 hours ago and
> I'd like to
> share the following graph which might be
> relevant to your second suggestion:
> image.png
> Note that the vertical dotted line denotes 26
> hours after the start of the original job.
> What we can
> observe here is that the amount of direct
> memory used is significantly reduced on the
> second job
> as a result of only excluding the Kafka sink.
> I think it could give you an idea of running
> with a DiscardingSink
> (I need to observe for the coming hours
> whether the same OOM exception occurs).
>
> Regarding the new KafkaSink, I need to modify
> the code and run it. I just checked on
> IntelliJ that
> FlinkKafkaProducer is now deprecated on 1.14.
> Is it recently deprecated? Anyway I'll share
> the result of running the pipeline with the
> new KafkaSink about 36 hours from the start of
> the jobs
> (as you can see from the above graph, it took
> around one and a half days for the job to get
> to the point.)
>
> Best,
>
> Dongwon
>
> On Wed, Nov 10, 2021 at 6:13 PM Fabian Paul
> <fa...@ververica.com> wrote:
>
> Hi Dongwon,
>
> Thanks for sharing the logs and the
> metrics screenshots with us. Unfortunately,
> I think we need more information to
> further isolate the problem therefore I have
> a couple of suggestions.
>
> 1. Since you already set up PromQL can you
> also share the JVM memory statics
> i.e. DirectMemory consumption over time? I
> would be interested to see whether
> the consumption is slowly increasing until
> the OOM happens or if it spikes
> only during the failing checkpoint.
>
> 2. We suspect that the Kafka Sink is
> causing the problem. Can you try to run
> your pipeline with a simple DiscadingSink
> and see if the error keeps happening?
> Maybe another component in your pipeline
> allocates a lot of DirectMemory and
> only the FlinkKafkaProducer hides the
> problems because it is the first component
> hitting the threshold.
> Another option would be to test the new
> KafkaSink which was released with 1.14
> and should replace the FlinkKafkaProducer.
>
> Best,
> Fabian
>
Re: how to expose the current in-flight async i/o requests as metrics?
Posted by Arvid Heise <ar...@apache.org>.
@Chesnay Schepler <ch...@apache.org>
, have you heard of any Java 11-specific issues with direct memory?
At this point, I'm actually excluding a bug in KafkaProducer and KafkaSink.
It may either be a bug in Kafka or Netty on Java 11.
On Fri, Nov 19, 2021 at 10:50 AM Dongwon Kim <ea...@gmail.com> wrote:
> Hi,
>
> For the last few days, I've tried the following, both of which seem to
> resolve the issue:
>
> 1. setting jdk.nio.maxCachedBufferSize for TMs on Java 11
> [image: image.png]
> I found some articles [1], [2] and an old post of Flink user ML [3], which
> said that a per-thread cache of direct memory can cause such an OOM
> problem. By setting a jdk.nio.maxCachedBufferSize property, I can observe
> the direct memory usage is no longer indefinitely increasing.
>
> 2. downgrade the Java version from 11 to 8 (even without setting
> jdk.nio.maxCachedBufferSize)
> [image: image.png]
> I don't know why Java 8 doesn't have any problems and Java 11 does.
>
> The below is with Java 11 without setting jdk.nio.maxCachedBufferSize:
> [image: image.png]
>
> Best,
>
> Dongwon
>
> [1] https://www.evanjones.ca/java-bytebuffer-leak.html
> [2]
> https://dzone.com/articles/troubleshooting-problems-with-native-off-heap-memo
> [3]
> http://mail-archives.apache.org/mod_mbox/flink-user/201712.mbox/%3CCANq+ctpiyNw1ueybQUgZJk4ciSyvfAmNq_1TA6NbnFxbfF+XHw@mail.gmail.com%3E
>
>
> On Wed, Nov 17, 2021 at 2:03 PM Dongwon Kim <ea...@gmail.com> wrote:
>
>> Hi Arvid,
>>
>> Unfortunately, even with Kafka 2.8.1 on Flink-1.14.0 for Scala 2.12,
>> the direct memory usage had been ever increasing:
>> [image: image.png]
>>
>> I double-checked that the newer version of Kafka client is used via TM
>> logs:
>>
>>> 2021-11-15 20:20:22,148 INFO org.apache.flink.yarn.
>>> YarnTaskExecutorRunner [] -
>>> --------------------------------------------------------------------------------
>>> 2021-11-15 20:20:22,156 INFO org.apache.flink.yarn.
>>> YarnTaskExecutorRunner [] - Starting YARN TaskExecutor runner (Version:
>>> 1.14.0, Scala: 2.12, Rev:460b386, Date:2021-09-22T08:39:40+02:00)
>>
>> // ...
>>> 2021-11-15 20:20:29,761 INFO org.apache.kafka.common.utils.AppInfoParser
>>> [] - Kafka version: 2.8.1
>>> 2021-11-15 20:20:29,761 INFO org.apache.kafka.common.utils.AppInfoParser
>>> [] - Kafka commitId: 839b886f9b732b15
>>> 2021-11-15 20:20:29,761 INFO org.apache.kafka.common.utils.AppInfoParser
>>> [] - Kafka startTimeMs: 1636975229757
>>> 2021-11-15 20:20:29,763 INFO org.apache.kafka.common.utils.AppInfoParser
>>> [] - Kafka version: 2.8.1
>>> 2021-11-15 20:20:29,763 INFO org.apache.kafka.common.utils.AppInfoParser
>>> [] - Kafka commitId: 839b886f9b732b15
>>> 2021-11-15 20:20:29,763 INFO org.apache.kafka.common.utils.AppInfoParser
>>> [] - Kafka startTimeMs: 1636975229758
>>> 2021-11-15 20:20:29,763 INFO org.apache.kafka.common.utils.AppInfoParser
>>> [] - Kafka version: 2.8.1
>>> 2021-11-15 20:20:29,764 INFO org.apache.kafka.common.utils.AppInfoParser
>>> [] - Kafka commitId: 839b886f9b732b15
>>> 2021-11-15 20:20:29,764 INFO org.apache.kafka.common.utils.AppInfoParser
>>> [] - Kafka startTimeMs: 1636975229758
>>> 2021-11-15 20:20:29,764 INFO org.apache.kafka.common.utils.AppInfoParser
>>> [] - Kafka version: 2.8.1
>>> 2021-11-15 20:20:29,764 INFO org.apache.kafka.common.utils.AppInfoParser
>>> [] - Kafka commitId: 839b886f9b732b15
>>> 2021-11-15 20:20:29,764 INFO org.apache.kafka.common.utils.AppInfoParser
>>> [] - Kafka startTimeMs: 1636975229758
>>
>> I attached the entire log message of a TM for the detailed information.
>>
>> While searching the web, I found that a guy from a Druid community told
>> about
>> Java 11 throwing OOM on Direct Buffer which didn't occur with Java 8 [1].
>> Few month ago,
>> I upgraded Java from 8 to 11 when Flink 1.10 was announced [2]. I'm going
>> to downgrade
>> Java from 11 to 8 and see whether the ever increasing direct memory will
>> be observed.
>>
>> [1] https://github.com/apache/druid/issues/5589#issuecomment-863112328
>> [2]
>> https://nightlies.apache.org/flink/flink-docs-release-1.10/release-notes/flink-1.10.html#java-11-support-flink-10725
>>
>> Best,
>>
>> Dongwon
>>
>> On Mon, Nov 15, 2021 at 4:57 PM Arvid Heise <ar...@apache.org> wrote:
>>
>>> Thanks for the throughout investigation.
>>>
>>> Do you have the luxury to bump the Kafka client version? For that, you
>>> need to run on Scala 2_12 and then you could bump Kafka to 2.8.1. I would
>>> be interested if the issue still persists.
>>>
>>> On Sun, Nov 14, 2021 at 3:16 PM Dongwon Kim <ea...@gmail.com>
>>> wrote:
>>>
>>>> Hi,
>>>>
>>>>
>>>>> 2. We suspect that the Kafka Sink is causing the problem. Can you try
>>>>> to run
>>>>> your pipeline with a simple DiscadingSink and see if the error keeps
>>>>> happening?
>>>>> Maybe another component in your pipeline allocates a lot of
>>>>> DirectMemory and
>>>>> only the FlinkKafkaProducer hides the problems because it is the first
>>>>> component
>>>>> hitting the threshold.
>>>>> Another option would be to test the new KafkaSink which was released
>>>>> with 1.14
>>>>> and should replace the FlinkKafkaProducer.
>>>>>
>>>>
>>>> I just launched a variant of the pipeline with DiscardingSink replacing
>>>> all KakfaSink.
>>>> As shown below, the direct memory usage does not go up with
>>>> DiscardingSink as with KafkaSink,
>>>> so I guess all the other components of the pipeline have nothing to do
>>>> with direct memory leak.
>>>> [image: image.png]
>>>>
>>>> One thing to note in the pipeline is that the size of output messages
>>>> to Kafka is not that small.
>>>> - 0.5 percentile : 33kb
>>>> - 0.75 percentile : 95kb
>>>> - 0.9 percentile : 243kb
>>>> - 0.95 percentile : 391kb
>>>> - 0.99 percentile : 810kb
>>>> - 0.999 percentile : 1.1MB
>>>> - 0.9999 percentile : 1.3MB
>>>> - 0.99999 percentile : 1.6MB
>>>> - 0.999999 percentile : 2.6MB
>>>> - FYI, the stats are computed for output messages for the last 24 hours
>>>>
>>>> Anyway, I need to increase the parallelism of kafka sinks and the
>>>> direct memory size for a while
>>>> to cope with the OOM problem.
>>>>
>>>> Best,
>>>>
>>>> Dongwon
>>>>
>>>>
>>>> On Sun, Nov 14, 2021 at 1:31 AM Dongwon Kim <ea...@gmail.com>
>>>> wrote:
>>>>
>>>>> Hi all,
>>>>>
>>>>> I also faced the same situation with the new KafkaSink. Below is the
>>>>> JVM directed memory over
>>>>> time and the attached is the JM log.
>>>>> [image: image.png]
>>>>>
>>>>> The new KafkaSink worked as I wanted: it caused JM to stop the whole
>>>>> pipeline and let me know
>>>>> which container had failed in JM log as follows:
>>>>>
>>>>> 2021-11-13 20:00:15,467 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Triggering checkpoint 77 (type=CHECKPOINT) @ 1636801215451 for job 63bcf8a835f5035370f60ca31f236cbf.
>>>>> 2021-11-13 20:00:29,840 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Completed checkpoint 77 for job 63bcf8a835f5035370f60ca31f236cbf (8694870137 bytes, checkpointDuration=14320 ms, finalizationTime=69 ms).
>>>>> 2021-11-13 20:00:29,844 INFO org.apache.flink.runtime.source.coordinator.SourceCoordinator [] - Marking checkpoint 77 as completed for source Source: kafka-source -> input-parser -> wm-gen -> navigps-filter.
>>>>> 2021-11-13 20:20:15,462 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Triggering checkpoint 78 (type=CHECKPOINT) @ 1636802415450 for job 63bcf8a835f5035370f60ca31f236cbf.
>>>>> 2021-11-13 20:20:27,725 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Completed checkpoint 78 for job 63bcf8a835f5035370f60ca31f236cbf (7422717674 bytes, checkpointDuration=12231 ms, finalizationTime=44 ms).
>>>>> 2021-11-13 20:20:27,728 INFO org.apache.flink.runtime.source.coordinator.SourceCoordinator [] - Marking checkpoint 78 as completed for source Source: kafka-source -> input-parser -> wm-gen -> navigps-filter.
>>>>> 2021-11-13 20:29:29,556 INFO org.apache.flink.runtime.executiongraph.ExecutionGraph [] - path-filter -> session-window -> (Sink late-data, session-filter -> enricher -> calculator -> (Sink kafka-sink, Sink kafka-sink-for-output-stats, filter-mm-failure -> Sink kafka-sink-for-mm-failure)) (10/64) (f75e736fa49e853d75b60428f30d5ca2) switched from RUNNING to FAILED on container_e141_1633577524620_0166_01_000002 @ mobdata-flink-dn22.dakao.io (dataPort=43902).
>>>>> org.apache.flink.util.FlinkRuntimeException: Failed to send data to Kafka null with FlinkKafkaInternalProducer{transactionalId='null', inTransaction=false, closed=false}
>>>>> at org.apache.flink.connector.kafka.sink.KafkaWriter$WriterCallback.throwException(KafkaWriter.java:402) ~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
>>>>> at org.apache.flink.connector.kafka.sink.KafkaWriter$WriterCallback.lambda$onCompletion$0(KafkaWriter.java:388) ~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
>>>>> at org.apache.flink.streaming.runtime.tasks.StreamTaskActionExecutor$1.runThrowing(StreamTaskActionExecutor.java:50) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
>>>>> at org.apache.flink.streaming.runtime.tasks.mailbox.Mail.run(Mail.java:90) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
>>>>> at org.apache.flink.streaming.runtime.tasks.mailbox.MailboxProcessor.processMailsNonBlocking(MailboxProcessor.java:353) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
>>>>> at org.apache.flink.streaming.runtime.tasks.mailbox.MailboxProcessor.processMail(MailboxProcessor.java:317) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
>>>>> at org.apache.flink.streaming.runtime.tasks.mailbox.MailboxProcessor.runMailboxLoop(MailboxProcessor.java:201) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
>>>>> at org.apache.flink.streaming.runtime.tasks.StreamTask.runMailboxLoop(StreamTask.java:809) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
>>>>> at org.apache.flink.streaming.runtime.tasks.StreamTask.invoke(StreamTask.java:761) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
>>>>> at org.apache.flink.runtime.taskmanager.Task.runWithSystemExitMonitoring(Task.java:958) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
>>>>> at org.apache.flink.runtime.taskmanager.Task.restoreAndInvoke(Task.java:937) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
>>>>> at org.apache.flink.runtime.taskmanager.Task.doRun(Task.java:766) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
>>>>> at org.apache.flink.runtime.taskmanager.Task.run(Task.java:575) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
>>>>> at java.lang.Thread.run(Thread.java:829) ~[?:?]
>>>>> Caused by: org.apache.kafka.common.errors.TimeoutException: Failed to allocate memory within the configured max blocking time 60000 ms.
>>>>>
>>>>>
>>>>> The other day I faced the similar exception (though it is not from
>>>>> Kafka producers):
>>>>>
>>>>> 2021-11-11 09:27:08,429 WARN org.apache.hadoop.hdfs.DataStreamer [] - DataStreamer Exception
>>>>> java.lang.OutOfMemoryError: Direct buffer memory
>>>>> at java.nio.Bits.reserveMemory(Bits.java:175) ~[?:?]
>>>>> at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:118) ~[?:?]
>>>>> at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:317) ~[?:?]
>>>>> at sun.nio.ch.Util.getTemporaryDirectBuffer(Util.java:242) ~[?:?]
>>>>> at sun.nio.ch.IOUtil.write(IOUtil.java:71) ~[?:?]
>>>>> at sun.nio.ch.IOUtil.write(IOUtil.java:50) ~[?:?]
>>>>> at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:462) ~[?:?]
>>>>> at org.apache.hadoop.net.SocketOutputStream$Writer.performIO(SocketOutputStream.java:63) ~[hadoop-common-3.1.1.3.1.4.0-315.jar:?]
>>>>> at org.apache.hadoop.net.SocketIOWithTimeout.doIO(SocketIOWithTimeout.java:142) ~[hadoop-common-3.1.1.3.1.4.0-315.jar:?]
>>>>> at org.apache.hadoop.net.SocketOutputStream.write(SocketOutputStream.java:159) ~[hadoop-common-3.1.1.3.1.4.0-315.jar:?]
>>>>> at org.apache.hadoop.net.SocketOutputStream.write(SocketOutputStream.java:117) ~[hadoop-common-3.1.1.3.1.4.0-315.jar:?]
>>>>> at java.io.BufferedOutputStream.write(BufferedOutputStream.java:123) ~[?:?]
>>>>> at java.io.DataOutputStream.write(DataOutputStream.java:107) ~[?:?]
>>>>> at org.apache.hadoop.hdfs.DFSPacket.writeTo(DFSPacket.java:194) ~[hadoop-hdfs-client-3.1.1.3.1.4.0-315.jar:?]
>>>>> at org.apache.hadoop.hdfs.DataStreamer.run(DataStreamer.java:774) [hadoop-hdfs-client-3.1.1.3.1.4.0-315.jar:?]
>>>>>
>>>>>
>>>>> Best,
>>>>>
>>>>> Dongwon
>>>>>
>>>>> On Wed, Nov 10, 2021 at 8:01 PM Dongwon Kim <ea...@gmail.com>
>>>>> wrote:
>>>>>
>>>>>> Hi Fabian,
>>>>>>
>>>>>> 1. Since you already set up PromQL can you also share the JVM memory
>>>>>>> statics
>>>>>>> i.e. DirectMemory consumption over time? I would be interested to
>>>>>>> see whether
>>>>>>> the consumption is slowly increasing until the OOM happens or if it
>>>>>>> spikes
>>>>>>> only during the failing checkpoint.
>>>>>>
>>>>>>
>>>>>> For all TMs:
>>>>>> [image: image.png]
>>>>>>
>>>>>> For the TM:
>>>>>> [image: image.png]
>>>>>>
>>>>>> 2. We suspect that the Kafka Sink is causing the problem. Can you try
>>>>>>> to run
>>>>>>> your pipeline with a simple DiscadingSink and see if the error keeps
>>>>>>> happening?
>>>>>>> Maybe another component in your pipeline allocates a lot of
>>>>>>> DirectMemory and
>>>>>>> only the FlinkKafkaProducer hides the problems because it is the
>>>>>>> first component
>>>>>>> hitting the threshold.
>>>>>>> Another option would be to test the new KafkaSink which was released
>>>>>>> with 1.14
>>>>>>> and should replace the FlinkKafkaProducer.
>>>>>>
>>>>>>
>>>>>> I launched a variant of the same pipeline without the problematic
>>>>>> sink 26 hours ago and I'd like to
>>>>>> share the following graph which might be relevant to your second
>>>>>> suggestion:
>>>>>> [image: image.png]
>>>>>> Note that the vertical dotted line denotes 26 hours after the start
>>>>>> of the original job. What we can
>>>>>> observe here is that the amount of direct memory used is
>>>>>> significantly reduced on the second job
>>>>>> as a result of only excluding the Kafka sink. I think it could give
>>>>>> you an idea of running with a DiscardingSink
>>>>>> (I need to observe for the coming hours whether the same OOM
>>>>>> exception occurs).
>>>>>>
>>>>>> Regarding the new KafkaSink, I need to modify the code and run it. I
>>>>>> just checked on IntelliJ that
>>>>>> FlinkKafkaProducer is now deprecated on 1.14. Is it recently
>>>>>> deprecated? Anyway I'll share
>>>>>> the result of running the pipeline with the new KafkaSink about 36
>>>>>> hours from the start of the jobs
>>>>>> (as you can see from the above graph, it took around one and a half
>>>>>> days for the job to get to the point.)
>>>>>>
>>>>>> Best,
>>>>>>
>>>>>> Dongwon
>>>>>>
>>>>>> On Wed, Nov 10, 2021 at 6:13 PM Fabian Paul <fa...@ververica.com>
>>>>>> wrote:
>>>>>>
>>>>>>> Hi Dongwon,
>>>>>>>
>>>>>>> Thanks for sharing the logs and the metrics screenshots with us.
>>>>>>> Unfortunately,
>>>>>>> I think we need more information to further isolate the problem
>>>>>>> therefore I have
>>>>>>> a couple of suggestions.
>>>>>>>
>>>>>>> 1. Since you already set up PromQL can you also share the JVM memory
>>>>>>> statics
>>>>>>> i.e. DirectMemory consumption over time? I would be interested to
>>>>>>> see whether
>>>>>>> the consumption is slowly increasing until the OOM happens or if it
>>>>>>> spikes
>>>>>>> only during the failing checkpoint.
>>>>>>>
>>>>>>> 2. We suspect that the Kafka Sink is causing the problem. Can you
>>>>>>> try to run
>>>>>>> your pipeline with a simple DiscadingSink and see if the error keeps
>>>>>>> happening?
>>>>>>> Maybe another component in your pipeline allocates a lot of
>>>>>>> DirectMemory and
>>>>>>> only the FlinkKafkaProducer hides the problems because it is the
>>>>>>> first component
>>>>>>> hitting the threshold.
>>>>>>> Another option would be to test the new KafkaSink which was released
>>>>>>> with 1.14
>>>>>>> and should replace the FlinkKafkaProducer.
>>>>>>>
>>>>>>> Best,
>>>>>>> Fabian
>>>>>>
>>>>>>
Re: how to expose the current in-flight async i/o requests as metrics?
Posted by Dongwon Kim <ea...@gmail.com>.
Hi,
For the last few days, I've tried the following, both of which seem to
resolve the issue:
1. setting jdk.nio.maxCachedBufferSize for TMs on Java 11
[image: image.png]
I found some articles [1], [2] and an old post of Flink user ML [3], which
said that a per-thread cache of direct memory can cause such an OOM
problem. By setting a jdk.nio.maxCachedBufferSize property, I can observe
the direct memory usage is no longer indefinitely increasing.
2. downgrade the Java version from 11 to 8 (even without setting
jdk.nio.maxCachedBufferSize)
[image: image.png]
I don't know why Java 8 doesn't have any problems and Java 11 does.
The below is with Java 11 without setting jdk.nio.maxCachedBufferSize:
[image: image.png]
Best,
Dongwon
[1] https://www.evanjones.ca/java-bytebuffer-leak.html
[2]
https://dzone.com/articles/troubleshooting-problems-with-native-off-heap-memo
[3]
http://mail-archives.apache.org/mod_mbox/flink-user/201712.mbox/%3CCANq+ctpiyNw1ueybQUgZJk4ciSyvfAmNq_1TA6NbnFxbfF+XHw@mail.gmail.com%3E
On Wed, Nov 17, 2021 at 2:03 PM Dongwon Kim <ea...@gmail.com> wrote:
> Hi Arvid,
>
> Unfortunately, even with Kafka 2.8.1 on Flink-1.14.0 for Scala 2.12,
> the direct memory usage had been ever increasing:
> [image: image.png]
>
> I double-checked that the newer version of Kafka client is used via TM
> logs:
>
>> 2021-11-15 20:20:22,148 INFO org.apache.flink.yarn.YarnTaskExecutorRunner
>> [] -
>> --------------------------------------------------------------------------------
>> 2021-11-15 20:20:22,156 INFO org.apache.flink.yarn.YarnTaskExecutorRunner
>> [] - Starting YARN TaskExecutor runner (Version: 1.14.0, Scala: 2.12, Rev
>> :460b386, Date:2021-09-22T08:39:40+02:00)
>
> // ...
>> 2021-11-15 20:20:29,761 INFO org.apache.kafka.common.utils.AppInfoParser
>> [] - Kafka version: 2.8.1
>> 2021-11-15 20:20:29,761 INFO org.apache.kafka.common.utils.AppInfoParser
>> [] - Kafka commitId: 839b886f9b732b15
>> 2021-11-15 20:20:29,761 INFO org.apache.kafka.common.utils.AppInfoParser
>> [] - Kafka startTimeMs: 1636975229757
>> 2021-11-15 20:20:29,763 INFO org.apache.kafka.common.utils.AppInfoParser
>> [] - Kafka version: 2.8.1
>> 2021-11-15 20:20:29,763 INFO org.apache.kafka.common.utils.AppInfoParser
>> [] - Kafka commitId: 839b886f9b732b15
>> 2021-11-15 20:20:29,763 INFO org.apache.kafka.common.utils.AppInfoParser
>> [] - Kafka startTimeMs: 1636975229758
>> 2021-11-15 20:20:29,763 INFO org.apache.kafka.common.utils.AppInfoParser
>> [] - Kafka version: 2.8.1
>> 2021-11-15 20:20:29,764 INFO org.apache.kafka.common.utils.AppInfoParser
>> [] - Kafka commitId: 839b886f9b732b15
>> 2021-11-15 20:20:29,764 INFO org.apache.kafka.common.utils.AppInfoParser
>> [] - Kafka startTimeMs: 1636975229758
>> 2021-11-15 20:20:29,764 INFO org.apache.kafka.common.utils.AppInfoParser
>> [] - Kafka version: 2.8.1
>> 2021-11-15 20:20:29,764 INFO org.apache.kafka.common.utils.AppInfoParser
>> [] - Kafka commitId: 839b886f9b732b15
>> 2021-11-15 20:20:29,764 INFO org.apache.kafka.common.utils.AppInfoParser
>> [] - Kafka startTimeMs: 1636975229758
>
> I attached the entire log message of a TM for the detailed information.
>
> While searching the web, I found that a guy from a Druid community told
> about
> Java 11 throwing OOM on Direct Buffer which didn't occur with Java 8 [1].
> Few month ago,
> I upgraded Java from 8 to 11 when Flink 1.10 was announced [2]. I'm going
> to downgrade
> Java from 11 to 8 and see whether the ever increasing direct memory will
> be observed.
>
> [1] https://github.com/apache/druid/issues/5589#issuecomment-863112328
> [2]
> https://nightlies.apache.org/flink/flink-docs-release-1.10/release-notes/flink-1.10.html#java-11-support-flink-10725
>
> Best,
>
> Dongwon
>
> On Mon, Nov 15, 2021 at 4:57 PM Arvid Heise <ar...@apache.org> wrote:
>
>> Thanks for the throughout investigation.
>>
>> Do you have the luxury to bump the Kafka client version? For that, you
>> need to run on Scala 2_12 and then you could bump Kafka to 2.8.1. I would
>> be interested if the issue still persists.
>>
>> On Sun, Nov 14, 2021 at 3:16 PM Dongwon Kim <ea...@gmail.com>
>> wrote:
>>
>>> Hi,
>>>
>>>
>>>> 2. We suspect that the Kafka Sink is causing the problem. Can you try
>>>> to run
>>>> your pipeline with a simple DiscadingSink and see if the error keeps
>>>> happening?
>>>> Maybe another component in your pipeline allocates a lot of
>>>> DirectMemory and
>>>> only the FlinkKafkaProducer hides the problems because it is the first
>>>> component
>>>> hitting the threshold.
>>>> Another option would be to test the new KafkaSink which was released
>>>> with 1.14
>>>> and should replace the FlinkKafkaProducer.
>>>>
>>>
>>> I just launched a variant of the pipeline with DiscardingSink replacing
>>> all KakfaSink.
>>> As shown below, the direct memory usage does not go up with
>>> DiscardingSink as with KafkaSink,
>>> so I guess all the other components of the pipeline have nothing to do
>>> with direct memory leak.
>>> [image: image.png]
>>>
>>> One thing to note in the pipeline is that the size of output messages to
>>> Kafka is not that small.
>>> - 0.5 percentile : 33kb
>>> - 0.75 percentile : 95kb
>>> - 0.9 percentile : 243kb
>>> - 0.95 percentile : 391kb
>>> - 0.99 percentile : 810kb
>>> - 0.999 percentile : 1.1MB
>>> - 0.9999 percentile : 1.3MB
>>> - 0.99999 percentile : 1.6MB
>>> - 0.999999 percentile : 2.6MB
>>> - FYI, the stats are computed for output messages for the last 24 hours
>>>
>>> Anyway, I need to increase the parallelism of kafka sinks and the direct
>>> memory size for a while
>>> to cope with the OOM problem.
>>>
>>> Best,
>>>
>>> Dongwon
>>>
>>>
>>> On Sun, Nov 14, 2021 at 1:31 AM Dongwon Kim <ea...@gmail.com>
>>> wrote:
>>>
>>>> Hi all,
>>>>
>>>> I also faced the same situation with the new KafkaSink. Below is the
>>>> JVM directed memory over
>>>> time and the attached is the JM log.
>>>> [image: image.png]
>>>>
>>>> The new KafkaSink worked as I wanted: it caused JM to stop the whole
>>>> pipeline and let me know
>>>> which container had failed in JM log as follows:
>>>>
>>>> 2021-11-13 20:00:15,467 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Triggering checkpoint 77 (type=CHECKPOINT) @ 1636801215451 for job 63bcf8a835f5035370f60ca31f236cbf.
>>>> 2021-11-13 20:00:29,840 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Completed checkpoint 77 for job 63bcf8a835f5035370f60ca31f236cbf (8694870137 bytes, checkpointDuration=14320 ms, finalizationTime=69 ms).
>>>> 2021-11-13 20:00:29,844 INFO org.apache.flink.runtime.source.coordinator.SourceCoordinator [] - Marking checkpoint 77 as completed for source Source: kafka-source -> input-parser -> wm-gen -> navigps-filter.
>>>> 2021-11-13 20:20:15,462 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Triggering checkpoint 78 (type=CHECKPOINT) @ 1636802415450 for job 63bcf8a835f5035370f60ca31f236cbf.
>>>> 2021-11-13 20:20:27,725 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Completed checkpoint 78 for job 63bcf8a835f5035370f60ca31f236cbf (7422717674 bytes, checkpointDuration=12231 ms, finalizationTime=44 ms).
>>>> 2021-11-13 20:20:27,728 INFO org.apache.flink.runtime.source.coordinator.SourceCoordinator [] - Marking checkpoint 78 as completed for source Source: kafka-source -> input-parser -> wm-gen -> navigps-filter.
>>>> 2021-11-13 20:29:29,556 INFO org.apache.flink.runtime.executiongraph.ExecutionGraph [] - path-filter -> session-window -> (Sink late-data, session-filter -> enricher -> calculator -> (Sink kafka-sink, Sink kafka-sink-for-output-stats, filter-mm-failure -> Sink kafka-sink-for-mm-failure)) (10/64) (f75e736fa49e853d75b60428f30d5ca2) switched from RUNNING to FAILED on container_e141_1633577524620_0166_01_000002 @ mobdata-flink-dn22.dakao.io (dataPort=43902).
>>>> org.apache.flink.util.FlinkRuntimeException: Failed to send data to Kafka null with FlinkKafkaInternalProducer{transactionalId='null', inTransaction=false, closed=false}
>>>> at org.apache.flink.connector.kafka.sink.KafkaWriter$WriterCallback.throwException(KafkaWriter.java:402) ~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
>>>> at org.apache.flink.connector.kafka.sink.KafkaWriter$WriterCallback.lambda$onCompletion$0(KafkaWriter.java:388) ~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
>>>> at org.apache.flink.streaming.runtime.tasks.StreamTaskActionExecutor$1.runThrowing(StreamTaskActionExecutor.java:50) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
>>>> at org.apache.flink.streaming.runtime.tasks.mailbox.Mail.run(Mail.java:90) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
>>>> at org.apache.flink.streaming.runtime.tasks.mailbox.MailboxProcessor.processMailsNonBlocking(MailboxProcessor.java:353) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
>>>> at org.apache.flink.streaming.runtime.tasks.mailbox.MailboxProcessor.processMail(MailboxProcessor.java:317) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
>>>> at org.apache.flink.streaming.runtime.tasks.mailbox.MailboxProcessor.runMailboxLoop(MailboxProcessor.java:201) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
>>>> at org.apache.flink.streaming.runtime.tasks.StreamTask.runMailboxLoop(StreamTask.java:809) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
>>>> at org.apache.flink.streaming.runtime.tasks.StreamTask.invoke(StreamTask.java:761) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
>>>> at org.apache.flink.runtime.taskmanager.Task.runWithSystemExitMonitoring(Task.java:958) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
>>>> at org.apache.flink.runtime.taskmanager.Task.restoreAndInvoke(Task.java:937) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
>>>> at org.apache.flink.runtime.taskmanager.Task.doRun(Task.java:766) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
>>>> at org.apache.flink.runtime.taskmanager.Task.run(Task.java:575) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
>>>> at java.lang.Thread.run(Thread.java:829) ~[?:?]
>>>> Caused by: org.apache.kafka.common.errors.TimeoutException: Failed to allocate memory within the configured max blocking time 60000 ms.
>>>>
>>>>
>>>> The other day I faced the similar exception (though it is not from
>>>> Kafka producers):
>>>>
>>>> 2021-11-11 09:27:08,429 WARN org.apache.hadoop.hdfs.DataStreamer [] - DataStreamer Exception
>>>> java.lang.OutOfMemoryError: Direct buffer memory
>>>> at java.nio.Bits.reserveMemory(Bits.java:175) ~[?:?]
>>>> at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:118) ~[?:?]
>>>> at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:317) ~[?:?]
>>>> at sun.nio.ch.Util.getTemporaryDirectBuffer(Util.java:242) ~[?:?]
>>>> at sun.nio.ch.IOUtil.write(IOUtil.java:71) ~[?:?]
>>>> at sun.nio.ch.IOUtil.write(IOUtil.java:50) ~[?:?]
>>>> at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:462) ~[?:?]
>>>> at org.apache.hadoop.net.SocketOutputStream$Writer.performIO(SocketOutputStream.java:63) ~[hadoop-common-3.1.1.3.1.4.0-315.jar:?]
>>>> at org.apache.hadoop.net.SocketIOWithTimeout.doIO(SocketIOWithTimeout.java:142) ~[hadoop-common-3.1.1.3.1.4.0-315.jar:?]
>>>> at org.apache.hadoop.net.SocketOutputStream.write(SocketOutputStream.java:159) ~[hadoop-common-3.1.1.3.1.4.0-315.jar:?]
>>>> at org.apache.hadoop.net.SocketOutputStream.write(SocketOutputStream.java:117) ~[hadoop-common-3.1.1.3.1.4.0-315.jar:?]
>>>> at java.io.BufferedOutputStream.write(BufferedOutputStream.java:123) ~[?:?]
>>>> at java.io.DataOutputStream.write(DataOutputStream.java:107) ~[?:?]
>>>> at org.apache.hadoop.hdfs.DFSPacket.writeTo(DFSPacket.java:194) ~[hadoop-hdfs-client-3.1.1.3.1.4.0-315.jar:?]
>>>> at org.apache.hadoop.hdfs.DataStreamer.run(DataStreamer.java:774) [hadoop-hdfs-client-3.1.1.3.1.4.0-315.jar:?]
>>>>
>>>>
>>>> Best,
>>>>
>>>> Dongwon
>>>>
>>>> On Wed, Nov 10, 2021 at 8:01 PM Dongwon Kim <ea...@gmail.com>
>>>> wrote:
>>>>
>>>>> Hi Fabian,
>>>>>
>>>>> 1. Since you already set up PromQL can you also share the JVM memory
>>>>>> statics
>>>>>> i.e. DirectMemory consumption over time? I would be interested to see
>>>>>> whether
>>>>>> the consumption is slowly increasing until the OOM happens or if it
>>>>>> spikes
>>>>>> only during the failing checkpoint.
>>>>>
>>>>>
>>>>> For all TMs:
>>>>> [image: image.png]
>>>>>
>>>>> For the TM:
>>>>> [image: image.png]
>>>>>
>>>>> 2. We suspect that the Kafka Sink is causing the problem. Can you try
>>>>>> to run
>>>>>> your pipeline with a simple DiscadingSink and see if the error keeps
>>>>>> happening?
>>>>>> Maybe another component in your pipeline allocates a lot of
>>>>>> DirectMemory and
>>>>>> only the FlinkKafkaProducer hides the problems because it is the
>>>>>> first component
>>>>>> hitting the threshold.
>>>>>> Another option would be to test the new KafkaSink which was released
>>>>>> with 1.14
>>>>>> and should replace the FlinkKafkaProducer.
>>>>>
>>>>>
>>>>> I launched a variant of the same pipeline without the problematic sink
>>>>> 26 hours ago and I'd like to
>>>>> share the following graph which might be relevant to your second
>>>>> suggestion:
>>>>> [image: image.png]
>>>>> Note that the vertical dotted line denotes 26 hours after the start of
>>>>> the original job. What we can
>>>>> observe here is that the amount of direct memory used is
>>>>> significantly reduced on the second job
>>>>> as a result of only excluding the Kafka sink. I think it could give
>>>>> you an idea of running with a DiscardingSink
>>>>> (I need to observe for the coming hours whether the same OOM exception
>>>>> occurs).
>>>>>
>>>>> Regarding the new KafkaSink, I need to modify the code and run it. I
>>>>> just checked on IntelliJ that
>>>>> FlinkKafkaProducer is now deprecated on 1.14. Is it recently
>>>>> deprecated? Anyway I'll share
>>>>> the result of running the pipeline with the new KafkaSink about 36
>>>>> hours from the start of the jobs
>>>>> (as you can see from the above graph, it took around one and a half
>>>>> days for the job to get to the point.)
>>>>>
>>>>> Best,
>>>>>
>>>>> Dongwon
>>>>>
>>>>> On Wed, Nov 10, 2021 at 6:13 PM Fabian Paul <fa...@ververica.com>
>>>>> wrote:
>>>>>
>>>>>> Hi Dongwon,
>>>>>>
>>>>>> Thanks for sharing the logs and the metrics screenshots with us.
>>>>>> Unfortunately,
>>>>>> I think we need more information to further isolate the problem
>>>>>> therefore I have
>>>>>> a couple of suggestions.
>>>>>>
>>>>>> 1. Since you already set up PromQL can you also share the JVM memory
>>>>>> statics
>>>>>> i.e. DirectMemory consumption over time? I would be interested to see
>>>>>> whether
>>>>>> the consumption is slowly increasing until the OOM happens or if it
>>>>>> spikes
>>>>>> only during the failing checkpoint.
>>>>>>
>>>>>> 2. We suspect that the Kafka Sink is causing the problem. Can you try
>>>>>> to run
>>>>>> your pipeline with a simple DiscadingSink and see if the error keeps
>>>>>> happening?
>>>>>> Maybe another component in your pipeline allocates a lot of
>>>>>> DirectMemory and
>>>>>> only the FlinkKafkaProducer hides the problems because it is the
>>>>>> first component
>>>>>> hitting the threshold.
>>>>>> Another option would be to test the new KafkaSink which was released
>>>>>> with 1.14
>>>>>> and should replace the FlinkKafkaProducer.
>>>>>>
>>>>>> Best,
>>>>>> Fabian
>>>>>
>>>>>
Re: how to expose the current in-flight async i/o requests as metrics?
Posted by Dongwon Kim <ea...@gmail.com>.
Hi Arvid,
Unfortunately, even with Kafka 2.8.1 on Flink-1.14.0 for Scala 2.12,
the direct memory usage had been ever increasing:
[image: image.png]
I double-checked that the newer version of Kafka client is used via TM logs:
> 2021-11-15 20:20:22,148 INFO org.apache.flink.yarn.YarnTaskExecutorRunner
> [] -
> --------------------------------------------------------------------------------
> 2021-11-15 20:20:22,156 INFO org.apache.flink.yarn.YarnTaskExecutorRunner
> [] - Starting YARN TaskExecutor runner (Version: 1.14.0, Scala: 2.12, Rev:
> 460b386, Date:2021-09-22T08:39:40+02:00)
// ...
> 2021-11-15 20:20:29,761 INFO org.apache.kafka.common.utils.AppInfoParser
> [] - Kafka version: 2.8.1
> 2021-11-15 20:20:29,761 INFO org.apache.kafka.common.utils.AppInfoParser
> [] - Kafka commitId: 839b886f9b732b15
> 2021-11-15 20:20:29,761 INFO org.apache.kafka.common.utils.AppInfoParser
> [] - Kafka startTimeMs: 1636975229757
> 2021-11-15 20:20:29,763 INFO org.apache.kafka.common.utils.AppInfoParser
> [] - Kafka version: 2.8.1
> 2021-11-15 20:20:29,763 INFO org.apache.kafka.common.utils.AppInfoParser
> [] - Kafka commitId: 839b886f9b732b15
> 2021-11-15 20:20:29,763 INFO org.apache.kafka.common.utils.AppInfoParser
> [] - Kafka startTimeMs: 1636975229758
> 2021-11-15 20:20:29,763 INFO org.apache.kafka.common.utils.AppInfoParser
> [] - Kafka version: 2.8.1
> 2021-11-15 20:20:29,764 INFO org.apache.kafka.common.utils.AppInfoParser
> [] - Kafka commitId: 839b886f9b732b15
> 2021-11-15 20:20:29,764 INFO org.apache.kafka.common.utils.AppInfoParser
> [] - Kafka startTimeMs: 1636975229758
> 2021-11-15 20:20:29,764 INFO org.apache.kafka.common.utils.AppInfoParser
> [] - Kafka version: 2.8.1
> 2021-11-15 20:20:29,764 INFO org.apache.kafka.common.utils.AppInfoParser
> [] - Kafka commitId: 839b886f9b732b15
> 2021-11-15 20:20:29,764 INFO org.apache.kafka.common.utils.AppInfoParser
> [] - Kafka startTimeMs: 1636975229758
I attached the entire log message of a TM for the detailed information.
While searching the web, I found that a guy from a Druid community told
about
Java 11 throwing OOM on Direct Buffer which didn't occur with Java 8 [1].
Few month ago,
I upgraded Java from 8 to 11 when Flink 1.10 was announced [2]. I'm going
to downgrade
Java from 11 to 8 and see whether the ever increasing direct memory will be
observed.
[1] https://github.com/apache/druid/issues/5589#issuecomment-863112328
[2]
https://nightlies.apache.org/flink/flink-docs-release-1.10/release-notes/flink-1.10.html#java-11-support-flink-10725
Best,
Dongwon
On Mon, Nov 15, 2021 at 4:57 PM Arvid Heise <ar...@apache.org> wrote:
> Thanks for the throughout investigation.
>
> Do you have the luxury to bump the Kafka client version? For that, you
> need to run on Scala 2_12 and then you could bump Kafka to 2.8.1. I would
> be interested if the issue still persists.
>
> On Sun, Nov 14, 2021 at 3:16 PM Dongwon Kim <ea...@gmail.com> wrote:
>
>> Hi,
>>
>>
>>> 2. We suspect that the Kafka Sink is causing the problem. Can you try to
>>> run
>>> your pipeline with a simple DiscadingSink and see if the error keeps
>>> happening?
>>> Maybe another component in your pipeline allocates a lot of DirectMemory
>>> and
>>> only the FlinkKafkaProducer hides the problems because it is the first
>>> component
>>> hitting the threshold.
>>> Another option would be to test the new KafkaSink which was released
>>> with 1.14
>>> and should replace the FlinkKafkaProducer.
>>>
>>
>> I just launched a variant of the pipeline with DiscardingSink replacing
>> all KakfaSink.
>> As shown below, the direct memory usage does not go up with
>> DiscardingSink as with KafkaSink,
>> so I guess all the other components of the pipeline have nothing to do
>> with direct memory leak.
>> [image: image.png]
>>
>> One thing to note in the pipeline is that the size of output messages to
>> Kafka is not that small.
>> - 0.5 percentile : 33kb
>> - 0.75 percentile : 95kb
>> - 0.9 percentile : 243kb
>> - 0.95 percentile : 391kb
>> - 0.99 percentile : 810kb
>> - 0.999 percentile : 1.1MB
>> - 0.9999 percentile : 1.3MB
>> - 0.99999 percentile : 1.6MB
>> - 0.999999 percentile : 2.6MB
>> - FYI, the stats are computed for output messages for the last 24 hours
>>
>> Anyway, I need to increase the parallelism of kafka sinks and the direct
>> memory size for a while
>> to cope with the OOM problem.
>>
>> Best,
>>
>> Dongwon
>>
>>
>> On Sun, Nov 14, 2021 at 1:31 AM Dongwon Kim <ea...@gmail.com>
>> wrote:
>>
>>> Hi all,
>>>
>>> I also faced the same situation with the new KafkaSink. Below is the JVM
>>> directed memory over
>>> time and the attached is the JM log.
>>> [image: image.png]
>>>
>>> The new KafkaSink worked as I wanted: it caused JM to stop the whole
>>> pipeline and let me know
>>> which container had failed in JM log as follows:
>>>
>>> 2021-11-13 20:00:15,467 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Triggering checkpoint 77 (type=CHECKPOINT) @ 1636801215451 for job 63bcf8a835f5035370f60ca31f236cbf.
>>> 2021-11-13 20:00:29,840 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Completed checkpoint 77 for job 63bcf8a835f5035370f60ca31f236cbf (8694870137 bytes, checkpointDuration=14320 ms, finalizationTime=69 ms).
>>> 2021-11-13 20:00:29,844 INFO org.apache.flink.runtime.source.coordinator.SourceCoordinator [] - Marking checkpoint 77 as completed for source Source: kafka-source -> input-parser -> wm-gen -> navigps-filter.
>>> 2021-11-13 20:20:15,462 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Triggering checkpoint 78 (type=CHECKPOINT) @ 1636802415450 for job 63bcf8a835f5035370f60ca31f236cbf.
>>> 2021-11-13 20:20:27,725 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Completed checkpoint 78 for job 63bcf8a835f5035370f60ca31f236cbf (7422717674 bytes, checkpointDuration=12231 ms, finalizationTime=44 ms).
>>> 2021-11-13 20:20:27,728 INFO org.apache.flink.runtime.source.coordinator.SourceCoordinator [] - Marking checkpoint 78 as completed for source Source: kafka-source -> input-parser -> wm-gen -> navigps-filter.
>>> 2021-11-13 20:29:29,556 INFO org.apache.flink.runtime.executiongraph.ExecutionGraph [] - path-filter -> session-window -> (Sink late-data, session-filter -> enricher -> calculator -> (Sink kafka-sink, Sink kafka-sink-for-output-stats, filter-mm-failure -> Sink kafka-sink-for-mm-failure)) (10/64) (f75e736fa49e853d75b60428f30d5ca2) switched from RUNNING to FAILED on container_e141_1633577524620_0166_01_000002 @ mobdata-flink-dn22.dakao.io (dataPort=43902).
>>> org.apache.flink.util.FlinkRuntimeException: Failed to send data to Kafka null with FlinkKafkaInternalProducer{transactionalId='null', inTransaction=false, closed=false}
>>> at org.apache.flink.connector.kafka.sink.KafkaWriter$WriterCallback.throwException(KafkaWriter.java:402) ~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
>>> at org.apache.flink.connector.kafka.sink.KafkaWriter$WriterCallback.lambda$onCompletion$0(KafkaWriter.java:388) ~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
>>> at org.apache.flink.streaming.runtime.tasks.StreamTaskActionExecutor$1.runThrowing(StreamTaskActionExecutor.java:50) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
>>> at org.apache.flink.streaming.runtime.tasks.mailbox.Mail.run(Mail.java:90) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
>>> at org.apache.flink.streaming.runtime.tasks.mailbox.MailboxProcessor.processMailsNonBlocking(MailboxProcessor.java:353) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
>>> at org.apache.flink.streaming.runtime.tasks.mailbox.MailboxProcessor.processMail(MailboxProcessor.java:317) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
>>> at org.apache.flink.streaming.runtime.tasks.mailbox.MailboxProcessor.runMailboxLoop(MailboxProcessor.java:201) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
>>> at org.apache.flink.streaming.runtime.tasks.StreamTask.runMailboxLoop(StreamTask.java:809) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
>>> at org.apache.flink.streaming.runtime.tasks.StreamTask.invoke(StreamTask.java:761) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
>>> at org.apache.flink.runtime.taskmanager.Task.runWithSystemExitMonitoring(Task.java:958) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
>>> at org.apache.flink.runtime.taskmanager.Task.restoreAndInvoke(Task.java:937) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
>>> at org.apache.flink.runtime.taskmanager.Task.doRun(Task.java:766) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
>>> at org.apache.flink.runtime.taskmanager.Task.run(Task.java:575) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
>>> at java.lang.Thread.run(Thread.java:829) ~[?:?]
>>> Caused by: org.apache.kafka.common.errors.TimeoutException: Failed to allocate memory within the configured max blocking time 60000 ms.
>>>
>>>
>>> The other day I faced the similar exception (though it is not from Kafka
>>> producers):
>>>
>>> 2021-11-11 09:27:08,429 WARN org.apache.hadoop.hdfs.DataStreamer [] - DataStreamer Exception
>>> java.lang.OutOfMemoryError: Direct buffer memory
>>> at java.nio.Bits.reserveMemory(Bits.java:175) ~[?:?]
>>> at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:118) ~[?:?]
>>> at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:317) ~[?:?]
>>> at sun.nio.ch.Util.getTemporaryDirectBuffer(Util.java:242) ~[?:?]
>>> at sun.nio.ch.IOUtil.write(IOUtil.java:71) ~[?:?]
>>> at sun.nio.ch.IOUtil.write(IOUtil.java:50) ~[?:?]
>>> at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:462) ~[?:?]
>>> at org.apache.hadoop.net.SocketOutputStream$Writer.performIO(SocketOutputStream.java:63) ~[hadoop-common-3.1.1.3.1.4.0-315.jar:?]
>>> at org.apache.hadoop.net.SocketIOWithTimeout.doIO(SocketIOWithTimeout.java:142) ~[hadoop-common-3.1.1.3.1.4.0-315.jar:?]
>>> at org.apache.hadoop.net.SocketOutputStream.write(SocketOutputStream.java:159) ~[hadoop-common-3.1.1.3.1.4.0-315.jar:?]
>>> at org.apache.hadoop.net.SocketOutputStream.write(SocketOutputStream.java:117) ~[hadoop-common-3.1.1.3.1.4.0-315.jar:?]
>>> at java.io.BufferedOutputStream.write(BufferedOutputStream.java:123) ~[?:?]
>>> at java.io.DataOutputStream.write(DataOutputStream.java:107) ~[?:?]
>>> at org.apache.hadoop.hdfs.DFSPacket.writeTo(DFSPacket.java:194) ~[hadoop-hdfs-client-3.1.1.3.1.4.0-315.jar:?]
>>> at org.apache.hadoop.hdfs.DataStreamer.run(DataStreamer.java:774) [hadoop-hdfs-client-3.1.1.3.1.4.0-315.jar:?]
>>>
>>>
>>> Best,
>>>
>>> Dongwon
>>>
>>> On Wed, Nov 10, 2021 at 8:01 PM Dongwon Kim <ea...@gmail.com>
>>> wrote:
>>>
>>>> Hi Fabian,
>>>>
>>>> 1. Since you already set up PromQL can you also share the JVM memory
>>>>> statics
>>>>> i.e. DirectMemory consumption over time? I would be interested to see
>>>>> whether
>>>>> the consumption is slowly increasing until the OOM happens or if it
>>>>> spikes
>>>>> only during the failing checkpoint.
>>>>
>>>>
>>>> For all TMs:
>>>> [image: image.png]
>>>>
>>>> For the TM:
>>>> [image: image.png]
>>>>
>>>> 2. We suspect that the Kafka Sink is causing the problem. Can you try
>>>>> to run
>>>>> your pipeline with a simple DiscadingSink and see if the error keeps
>>>>> happening?
>>>>> Maybe another component in your pipeline allocates a lot of
>>>>> DirectMemory and
>>>>> only the FlinkKafkaProducer hides the problems because it is the first
>>>>> component
>>>>> hitting the threshold.
>>>>> Another option would be to test the new KafkaSink which was released
>>>>> with 1.14
>>>>> and should replace the FlinkKafkaProducer.
>>>>
>>>>
>>>> I launched a variant of the same pipeline without the problematic sink
>>>> 26 hours ago and I'd like to
>>>> share the following graph which might be relevant to your second
>>>> suggestion:
>>>> [image: image.png]
>>>> Note that the vertical dotted line denotes 26 hours after the start of
>>>> the original job. What we can
>>>> observe here is that the amount of direct memory used is
>>>> significantly reduced on the second job
>>>> as a result of only excluding the Kafka sink. I think it could give you
>>>> an idea of running with a DiscardingSink
>>>> (I need to observe for the coming hours whether the same OOM exception
>>>> occurs).
>>>>
>>>> Regarding the new KafkaSink, I need to modify the code and run it. I
>>>> just checked on IntelliJ that
>>>> FlinkKafkaProducer is now deprecated on 1.14. Is it recently
>>>> deprecated? Anyway I'll share
>>>> the result of running the pipeline with the new KafkaSink about 36
>>>> hours from the start of the jobs
>>>> (as you can see from the above graph, it took around one and a half
>>>> days for the job to get to the point.)
>>>>
>>>> Best,
>>>>
>>>> Dongwon
>>>>
>>>> On Wed, Nov 10, 2021 at 6:13 PM Fabian Paul <fa...@ververica.com>
>>>> wrote:
>>>>
>>>>> Hi Dongwon,
>>>>>
>>>>> Thanks for sharing the logs and the metrics screenshots with us.
>>>>> Unfortunately,
>>>>> I think we need more information to further isolate the problem
>>>>> therefore I have
>>>>> a couple of suggestions.
>>>>>
>>>>> 1. Since you already set up PromQL can you also share the JVM memory
>>>>> statics
>>>>> i.e. DirectMemory consumption over time? I would be interested to see
>>>>> whether
>>>>> the consumption is slowly increasing until the OOM happens or if it
>>>>> spikes
>>>>> only during the failing checkpoint.
>>>>>
>>>>> 2. We suspect that the Kafka Sink is causing the problem. Can you try
>>>>> to run
>>>>> your pipeline with a simple DiscadingSink and see if the error keeps
>>>>> happening?
>>>>> Maybe another component in your pipeline allocates a lot of
>>>>> DirectMemory and
>>>>> only the FlinkKafkaProducer hides the problems because it is the first
>>>>> component
>>>>> hitting the threshold.
>>>>> Another option would be to test the new KafkaSink which was released
>>>>> with 1.14
>>>>> and should replace the FlinkKafkaProducer.
>>>>>
>>>>> Best,
>>>>> Fabian
>>>>
>>>>
Re: how to expose the current in-flight async i/o requests as metrics?
Posted by Arvid Heise <ar...@apache.org>.
Thanks for the throughout investigation.
Do you have the luxury to bump the Kafka client version? For that, you need
to run on Scala 2_12 and then you could bump Kafka to 2.8.1. I would be
interested if the issue still persists.
On Sun, Nov 14, 2021 at 3:16 PM Dongwon Kim <ea...@gmail.com> wrote:
> Hi,
>
>
>> 2. We suspect that the Kafka Sink is causing the problem. Can you try to
>> run
>> your pipeline with a simple DiscadingSink and see if the error keeps
>> happening?
>> Maybe another component in your pipeline allocates a lot of DirectMemory
>> and
>> only the FlinkKafkaProducer hides the problems because it is the first
>> component
>> hitting the threshold.
>> Another option would be to test the new KafkaSink which was released with
>> 1.14
>> and should replace the FlinkKafkaProducer.
>>
>
> I just launched a variant of the pipeline with DiscardingSink replacing
> all KakfaSink.
> As shown below, the direct memory usage does not go up with DiscardingSink
> as with KafkaSink,
> so I guess all the other components of the pipeline have nothing to do
> with direct memory leak.
> [image: image.png]
>
> One thing to note in the pipeline is that the size of output messages to
> Kafka is not that small.
> - 0.5 percentile : 33kb
> - 0.75 percentile : 95kb
> - 0.9 percentile : 243kb
> - 0.95 percentile : 391kb
> - 0.99 percentile : 810kb
> - 0.999 percentile : 1.1MB
> - 0.9999 percentile : 1.3MB
> - 0.99999 percentile : 1.6MB
> - 0.999999 percentile : 2.6MB
> - FYI, the stats are computed for output messages for the last 24 hours
>
> Anyway, I need to increase the parallelism of kafka sinks and the direct
> memory size for a while
> to cope with the OOM problem.
>
> Best,
>
> Dongwon
>
>
> On Sun, Nov 14, 2021 at 1:31 AM Dongwon Kim <ea...@gmail.com> wrote:
>
>> Hi all,
>>
>> I also faced the same situation with the new KafkaSink. Below is the JVM
>> directed memory over
>> time and the attached is the JM log.
>> [image: image.png]
>>
>> The new KafkaSink worked as I wanted: it caused JM to stop the whole
>> pipeline and let me know
>> which container had failed in JM log as follows:
>>
>> 2021-11-13 20:00:15,467 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Triggering checkpoint 77 (type=CHECKPOINT) @ 1636801215451 for job 63bcf8a835f5035370f60ca31f236cbf.
>> 2021-11-13 20:00:29,840 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Completed checkpoint 77 for job 63bcf8a835f5035370f60ca31f236cbf (8694870137 bytes, checkpointDuration=14320 ms, finalizationTime=69 ms).
>> 2021-11-13 20:00:29,844 INFO org.apache.flink.runtime.source.coordinator.SourceCoordinator [] - Marking checkpoint 77 as completed for source Source: kafka-source -> input-parser -> wm-gen -> navigps-filter.
>> 2021-11-13 20:20:15,462 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Triggering checkpoint 78 (type=CHECKPOINT) @ 1636802415450 for job 63bcf8a835f5035370f60ca31f236cbf.
>> 2021-11-13 20:20:27,725 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Completed checkpoint 78 for job 63bcf8a835f5035370f60ca31f236cbf (7422717674 bytes, checkpointDuration=12231 ms, finalizationTime=44 ms).
>> 2021-11-13 20:20:27,728 INFO org.apache.flink.runtime.source.coordinator.SourceCoordinator [] - Marking checkpoint 78 as completed for source Source: kafka-source -> input-parser -> wm-gen -> navigps-filter.
>> 2021-11-13 20:29:29,556 INFO org.apache.flink.runtime.executiongraph.ExecutionGraph [] - path-filter -> session-window -> (Sink late-data, session-filter -> enricher -> calculator -> (Sink kafka-sink, Sink kafka-sink-for-output-stats, filter-mm-failure -> Sink kafka-sink-for-mm-failure)) (10/64) (f75e736fa49e853d75b60428f30d5ca2) switched from RUNNING to FAILED on container_e141_1633577524620_0166_01_000002 @ mobdata-flink-dn22.dakao.io (dataPort=43902).
>> org.apache.flink.util.FlinkRuntimeException: Failed to send data to Kafka null with FlinkKafkaInternalProducer{transactionalId='null', inTransaction=false, closed=false}
>> at org.apache.flink.connector.kafka.sink.KafkaWriter$WriterCallback.throwException(KafkaWriter.java:402) ~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
>> at org.apache.flink.connector.kafka.sink.KafkaWriter$WriterCallback.lambda$onCompletion$0(KafkaWriter.java:388) ~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
>> at org.apache.flink.streaming.runtime.tasks.StreamTaskActionExecutor$1.runThrowing(StreamTaskActionExecutor.java:50) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
>> at org.apache.flink.streaming.runtime.tasks.mailbox.Mail.run(Mail.java:90) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
>> at org.apache.flink.streaming.runtime.tasks.mailbox.MailboxProcessor.processMailsNonBlocking(MailboxProcessor.java:353) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
>> at org.apache.flink.streaming.runtime.tasks.mailbox.MailboxProcessor.processMail(MailboxProcessor.java:317) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
>> at org.apache.flink.streaming.runtime.tasks.mailbox.MailboxProcessor.runMailboxLoop(MailboxProcessor.java:201) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
>> at org.apache.flink.streaming.runtime.tasks.StreamTask.runMailboxLoop(StreamTask.java:809) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
>> at org.apache.flink.streaming.runtime.tasks.StreamTask.invoke(StreamTask.java:761) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
>> at org.apache.flink.runtime.taskmanager.Task.runWithSystemExitMonitoring(Task.java:958) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
>> at org.apache.flink.runtime.taskmanager.Task.restoreAndInvoke(Task.java:937) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
>> at org.apache.flink.runtime.taskmanager.Task.doRun(Task.java:766) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
>> at org.apache.flink.runtime.taskmanager.Task.run(Task.java:575) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
>> at java.lang.Thread.run(Thread.java:829) ~[?:?]
>> Caused by: org.apache.kafka.common.errors.TimeoutException: Failed to allocate memory within the configured max blocking time 60000 ms.
>>
>>
>> The other day I faced the similar exception (though it is not from Kafka
>> producers):
>>
>> 2021-11-11 09:27:08,429 WARN org.apache.hadoop.hdfs.DataStreamer [] - DataStreamer Exception
>> java.lang.OutOfMemoryError: Direct buffer memory
>> at java.nio.Bits.reserveMemory(Bits.java:175) ~[?:?]
>> at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:118) ~[?:?]
>> at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:317) ~[?:?]
>> at sun.nio.ch.Util.getTemporaryDirectBuffer(Util.java:242) ~[?:?]
>> at sun.nio.ch.IOUtil.write(IOUtil.java:71) ~[?:?]
>> at sun.nio.ch.IOUtil.write(IOUtil.java:50) ~[?:?]
>> at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:462) ~[?:?]
>> at org.apache.hadoop.net.SocketOutputStream$Writer.performIO(SocketOutputStream.java:63) ~[hadoop-common-3.1.1.3.1.4.0-315.jar:?]
>> at org.apache.hadoop.net.SocketIOWithTimeout.doIO(SocketIOWithTimeout.java:142) ~[hadoop-common-3.1.1.3.1.4.0-315.jar:?]
>> at org.apache.hadoop.net.SocketOutputStream.write(SocketOutputStream.java:159) ~[hadoop-common-3.1.1.3.1.4.0-315.jar:?]
>> at org.apache.hadoop.net.SocketOutputStream.write(SocketOutputStream.java:117) ~[hadoop-common-3.1.1.3.1.4.0-315.jar:?]
>> at java.io.BufferedOutputStream.write(BufferedOutputStream.java:123) ~[?:?]
>> at java.io.DataOutputStream.write(DataOutputStream.java:107) ~[?:?]
>> at org.apache.hadoop.hdfs.DFSPacket.writeTo(DFSPacket.java:194) ~[hadoop-hdfs-client-3.1.1.3.1.4.0-315.jar:?]
>> at org.apache.hadoop.hdfs.DataStreamer.run(DataStreamer.java:774) [hadoop-hdfs-client-3.1.1.3.1.4.0-315.jar:?]
>>
>>
>> Best,
>>
>> Dongwon
>>
>> On Wed, Nov 10, 2021 at 8:01 PM Dongwon Kim <ea...@gmail.com>
>> wrote:
>>
>>> Hi Fabian,
>>>
>>> 1. Since you already set up PromQL can you also share the JVM memory
>>>> statics
>>>> i.e. DirectMemory consumption over time? I would be interested to see
>>>> whether
>>>> the consumption is slowly increasing until the OOM happens or if it
>>>> spikes
>>>> only during the failing checkpoint.
>>>
>>>
>>> For all TMs:
>>> [image: image.png]
>>>
>>> For the TM:
>>> [image: image.png]
>>>
>>> 2. We suspect that the Kafka Sink is causing the problem. Can you try to
>>>> run
>>>> your pipeline with a simple DiscadingSink and see if the error keeps
>>>> happening?
>>>> Maybe another component in your pipeline allocates a lot of
>>>> DirectMemory and
>>>> only the FlinkKafkaProducer hides the problems because it is the first
>>>> component
>>>> hitting the threshold.
>>>> Another option would be to test the new KafkaSink which was released
>>>> with 1.14
>>>> and should replace the FlinkKafkaProducer.
>>>
>>>
>>> I launched a variant of the same pipeline without the problematic sink
>>> 26 hours ago and I'd like to
>>> share the following graph which might be relevant to your second
>>> suggestion:
>>> [image: image.png]
>>> Note that the vertical dotted line denotes 26 hours after the start of
>>> the original job. What we can
>>> observe here is that the amount of direct memory used is
>>> significantly reduced on the second job
>>> as a result of only excluding the Kafka sink. I think it could give you
>>> an idea of running with a DiscardingSink
>>> (I need to observe for the coming hours whether the same OOM exception
>>> occurs).
>>>
>>> Regarding the new KafkaSink, I need to modify the code and run it. I
>>> just checked on IntelliJ that
>>> FlinkKafkaProducer is now deprecated on 1.14. Is it recently deprecated?
>>> Anyway I'll share
>>> the result of running the pipeline with the new KafkaSink about 36 hours
>>> from the start of the jobs
>>> (as you can see from the above graph, it took around one and a half days
>>> for the job to get to the point.)
>>>
>>> Best,
>>>
>>> Dongwon
>>>
>>> On Wed, Nov 10, 2021 at 6:13 PM Fabian Paul <fa...@ververica.com>
>>> wrote:
>>>
>>>> Hi Dongwon,
>>>>
>>>> Thanks for sharing the logs and the metrics screenshots with us.
>>>> Unfortunately,
>>>> I think we need more information to further isolate the problem
>>>> therefore I have
>>>> a couple of suggestions.
>>>>
>>>> 1. Since you already set up PromQL can you also share the JVM memory
>>>> statics
>>>> i.e. DirectMemory consumption over time? I would be interested to see
>>>> whether
>>>> the consumption is slowly increasing until the OOM happens or if it
>>>> spikes
>>>> only during the failing checkpoint.
>>>>
>>>> 2. We suspect that the Kafka Sink is causing the problem. Can you try
>>>> to run
>>>> your pipeline with a simple DiscadingSink and see if the error keeps
>>>> happening?
>>>> Maybe another component in your pipeline allocates a lot of
>>>> DirectMemory and
>>>> only the FlinkKafkaProducer hides the problems because it is the first
>>>> component
>>>> hitting the threshold.
>>>> Another option would be to test the new KafkaSink which was released
>>>> with 1.14
>>>> and should replace the FlinkKafkaProducer.
>>>>
>>>> Best,
>>>> Fabian
>>>
>>>
Re: how to expose the current in-flight async i/o requests as metrics?
Posted by Dongwon Kim <ea...@gmail.com>.
Hi,
> 2. We suspect that the Kafka Sink is causing the problem. Can you try to
> run
> your pipeline with a simple DiscadingSink and see if the error keeps
> happening?
> Maybe another component in your pipeline allocates a lot of DirectMemory
> and
> only the FlinkKafkaProducer hides the problems because it is the first
> component
> hitting the threshold.
> Another option would be to test the new KafkaSink which was released with
> 1.14
> and should replace the FlinkKafkaProducer.
>
I just launched a variant of the pipeline with DiscardingSink replacing all
KakfaSink.
As shown below, the direct memory usage does not go up with DiscardingSink
as with KafkaSink,
so I guess all the other components of the pipeline have nothing to do with
direct memory leak.
[image: image.png]
One thing to note in the pipeline is that the size of output messages to
Kafka is not that small.
- 0.5 percentile : 33kb
- 0.75 percentile : 95kb
- 0.9 percentile : 243kb
- 0.95 percentile : 391kb
- 0.99 percentile : 810kb
- 0.999 percentile : 1.1MB
- 0.9999 percentile : 1.3MB
- 0.99999 percentile : 1.6MB
- 0.999999 percentile : 2.6MB
- FYI, the stats are computed for output messages for the last 24 hours
Anyway, I need to increase the parallelism of kafka sinks and the direct
memory size for a while
to cope with the OOM problem.
Best,
Dongwon
On Sun, Nov 14, 2021 at 1:31 AM Dongwon Kim <ea...@gmail.com> wrote:
> Hi all,
>
> I also faced the same situation with the new KafkaSink. Below is the JVM
> directed memory over
> time and the attached is the JM log.
> [image: image.png]
>
> The new KafkaSink worked as I wanted: it caused JM to stop the whole
> pipeline and let me know
> which container had failed in JM log as follows:
>
> 2021-11-13 20:00:15,467 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Triggering checkpoint 77 (type=CHECKPOINT) @ 1636801215451 for job 63bcf8a835f5035370f60ca31f236cbf.
> 2021-11-13 20:00:29,840 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Completed checkpoint 77 for job 63bcf8a835f5035370f60ca31f236cbf (8694870137 bytes, checkpointDuration=14320 ms, finalizationTime=69 ms).
> 2021-11-13 20:00:29,844 INFO org.apache.flink.runtime.source.coordinator.SourceCoordinator [] - Marking checkpoint 77 as completed for source Source: kafka-source -> input-parser -> wm-gen -> navigps-filter.
> 2021-11-13 20:20:15,462 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Triggering checkpoint 78 (type=CHECKPOINT) @ 1636802415450 for job 63bcf8a835f5035370f60ca31f236cbf.
> 2021-11-13 20:20:27,725 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Completed checkpoint 78 for job 63bcf8a835f5035370f60ca31f236cbf (7422717674 bytes, checkpointDuration=12231 ms, finalizationTime=44 ms).
> 2021-11-13 20:20:27,728 INFO org.apache.flink.runtime.source.coordinator.SourceCoordinator [] - Marking checkpoint 78 as completed for source Source: kafka-source -> input-parser -> wm-gen -> navigps-filter.
> 2021-11-13 20:29:29,556 INFO org.apache.flink.runtime.executiongraph.ExecutionGraph [] - path-filter -> session-window -> (Sink late-data, session-filter -> enricher -> calculator -> (Sink kafka-sink, Sink kafka-sink-for-output-stats, filter-mm-failure -> Sink kafka-sink-for-mm-failure)) (10/64) (f75e736fa49e853d75b60428f30d5ca2) switched from RUNNING to FAILED on container_e141_1633577524620_0166_01_000002 @ mobdata-flink-dn22.dakao.io (dataPort=43902).
> org.apache.flink.util.FlinkRuntimeException: Failed to send data to Kafka null with FlinkKafkaInternalProducer{transactionalId='null', inTransaction=false, closed=false}
> at org.apache.flink.connector.kafka.sink.KafkaWriter$WriterCallback.throwException(KafkaWriter.java:402) ~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
> at org.apache.flink.connector.kafka.sink.KafkaWriter$WriterCallback.lambda$onCompletion$0(KafkaWriter.java:388) ~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
> at org.apache.flink.streaming.runtime.tasks.StreamTaskActionExecutor$1.runThrowing(StreamTaskActionExecutor.java:50) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
> at org.apache.flink.streaming.runtime.tasks.mailbox.Mail.run(Mail.java:90) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
> at org.apache.flink.streaming.runtime.tasks.mailbox.MailboxProcessor.processMailsNonBlocking(MailboxProcessor.java:353) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
> at org.apache.flink.streaming.runtime.tasks.mailbox.MailboxProcessor.processMail(MailboxProcessor.java:317) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
> at org.apache.flink.streaming.runtime.tasks.mailbox.MailboxProcessor.runMailboxLoop(MailboxProcessor.java:201) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
> at org.apache.flink.streaming.runtime.tasks.StreamTask.runMailboxLoop(StreamTask.java:809) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
> at org.apache.flink.streaming.runtime.tasks.StreamTask.invoke(StreamTask.java:761) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
> at org.apache.flink.runtime.taskmanager.Task.runWithSystemExitMonitoring(Task.java:958) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
> at org.apache.flink.runtime.taskmanager.Task.restoreAndInvoke(Task.java:937) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
> at org.apache.flink.runtime.taskmanager.Task.doRun(Task.java:766) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
> at org.apache.flink.runtime.taskmanager.Task.run(Task.java:575) ~[flink-dist_2.11-1.14.0.jar:1.14.0]
> at java.lang.Thread.run(Thread.java:829) ~[?:?]
> Caused by: org.apache.kafka.common.errors.TimeoutException: Failed to allocate memory within the configured max blocking time 60000 ms.
>
>
> The other day I faced the similar exception (though it is not from Kafka
> producers):
>
> 2021-11-11 09:27:08,429 WARN org.apache.hadoop.hdfs.DataStreamer [] - DataStreamer Exception
> java.lang.OutOfMemoryError: Direct buffer memory
> at java.nio.Bits.reserveMemory(Bits.java:175) ~[?:?]
> at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:118) ~[?:?]
> at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:317) ~[?:?]
> at sun.nio.ch.Util.getTemporaryDirectBuffer(Util.java:242) ~[?:?]
> at sun.nio.ch.IOUtil.write(IOUtil.java:71) ~[?:?]
> at sun.nio.ch.IOUtil.write(IOUtil.java:50) ~[?:?]
> at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:462) ~[?:?]
> at org.apache.hadoop.net.SocketOutputStream$Writer.performIO(SocketOutputStream.java:63) ~[hadoop-common-3.1.1.3.1.4.0-315.jar:?]
> at org.apache.hadoop.net.SocketIOWithTimeout.doIO(SocketIOWithTimeout.java:142) ~[hadoop-common-3.1.1.3.1.4.0-315.jar:?]
> at org.apache.hadoop.net.SocketOutputStream.write(SocketOutputStream.java:159) ~[hadoop-common-3.1.1.3.1.4.0-315.jar:?]
> at org.apache.hadoop.net.SocketOutputStream.write(SocketOutputStream.java:117) ~[hadoop-common-3.1.1.3.1.4.0-315.jar:?]
> at java.io.BufferedOutputStream.write(BufferedOutputStream.java:123) ~[?:?]
> at java.io.DataOutputStream.write(DataOutputStream.java:107) ~[?:?]
> at org.apache.hadoop.hdfs.DFSPacket.writeTo(DFSPacket.java:194) ~[hadoop-hdfs-client-3.1.1.3.1.4.0-315.jar:?]
> at org.apache.hadoop.hdfs.DataStreamer.run(DataStreamer.java:774) [hadoop-hdfs-client-3.1.1.3.1.4.0-315.jar:?]
>
>
> Best,
>
> Dongwon
>
> On Wed, Nov 10, 2021 at 8:01 PM Dongwon Kim <ea...@gmail.com> wrote:
>
>> Hi Fabian,
>>
>> 1. Since you already set up PromQL can you also share the JVM memory
>>> statics
>>> i.e. DirectMemory consumption over time? I would be interested to see
>>> whether
>>> the consumption is slowly increasing until the OOM happens or if it
>>> spikes
>>> only during the failing checkpoint.
>>
>>
>> For all TMs:
>> [image: image.png]
>>
>> For the TM:
>> [image: image.png]
>>
>> 2. We suspect that the Kafka Sink is causing the problem. Can you try to
>>> run
>>> your pipeline with a simple DiscadingSink and see if the error keeps
>>> happening?
>>> Maybe another component in your pipeline allocates a lot of DirectMemory
>>> and
>>> only the FlinkKafkaProducer hides the problems because it is the first
>>> component
>>> hitting the threshold.
>>> Another option would be to test the new KafkaSink which was released
>>> with 1.14
>>> and should replace the FlinkKafkaProducer.
>>
>>
>> I launched a variant of the same pipeline without the problematic sink 26
>> hours ago and I'd like to
>> share the following graph which might be relevant to your second
>> suggestion:
>> [image: image.png]
>> Note that the vertical dotted line denotes 26 hours after the start of
>> the original job. What we can
>> observe here is that the amount of direct memory used is
>> significantly reduced on the second job
>> as a result of only excluding the Kafka sink. I think it could give you
>> an idea of running with a DiscardingSink
>> (I need to observe for the coming hours whether the same OOM exception
>> occurs).
>>
>> Regarding the new KafkaSink, I need to modify the code and run it. I
>> just checked on IntelliJ that
>> FlinkKafkaProducer is now deprecated on 1.14. Is it recently deprecated?
>> Anyway I'll share
>> the result of running the pipeline with the new KafkaSink about 36 hours
>> from the start of the jobs
>> (as you can see from the above graph, it took around one and a half days
>> for the job to get to the point.)
>>
>> Best,
>>
>> Dongwon
>>
>> On Wed, Nov 10, 2021 at 6:13 PM Fabian Paul <fa...@ververica.com>
>> wrote:
>>
>>> Hi Dongwon,
>>>
>>> Thanks for sharing the logs and the metrics screenshots with us.
>>> Unfortunately,
>>> I think we need more information to further isolate the problem
>>> therefore I have
>>> a couple of suggestions.
>>>
>>> 1. Since you already set up PromQL can you also share the JVM memory
>>> statics
>>> i.e. DirectMemory consumption over time? I would be interested to see
>>> whether
>>> the consumption is slowly increasing until the OOM happens or if it
>>> spikes
>>> only during the failing checkpoint.
>>>
>>> 2. We suspect that the Kafka Sink is causing the problem. Can you try to
>>> run
>>> your pipeline with a simple DiscadingSink and see if the error keeps
>>> happening?
>>> Maybe another component in your pipeline allocates a lot of DirectMemory
>>> and
>>> only the FlinkKafkaProducer hides the problems because it is the first
>>> component
>>> hitting the threshold.
>>> Another option would be to test the new KafkaSink which was released
>>> with 1.14
>>> and should replace the FlinkKafkaProducer.
>>>
>>> Best,
>>> Fabian
>>
>>
Re: how to expose the current in-flight async i/o requests as metrics?
Posted by Dongwon Kim <ea...@gmail.com>.
Hi all,
I also faced the same situation with the new KafkaSink. Below is the JVM
directed memory over
time and the attached is the JM log.
[image: image.png]
The new KafkaSink worked as I wanted: it caused JM to stop the whole
pipeline and let me know
which container had failed in JM log as follows:
2021-11-13 20:00:15,467 INFO
org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] -
Triggering checkpoint 77 (type=CHECKPOINT) @ 1636801215451 for job
63bcf8a835f5035370f60ca31f236cbf.
2021-11-13 20:00:29,840 INFO
org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] -
Completed checkpoint 77 for job 63bcf8a835f5035370f60ca31f236cbf
(8694870137 bytes, checkpointDuration=14320 ms, finalizationTime=69
ms).
2021-11-13 20:00:29,844 INFO
org.apache.flink.runtime.source.coordinator.SourceCoordinator [] -
Marking checkpoint 77 as completed for source Source: kafka-source ->
input-parser -> wm-gen -> navigps-filter.
2021-11-13 20:20:15,462 INFO
org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] -
Triggering checkpoint 78 (type=CHECKPOINT) @ 1636802415450 for job
63bcf8a835f5035370f60ca31f236cbf.
2021-11-13 20:20:27,725 INFO
org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] -
Completed checkpoint 78 for job 63bcf8a835f5035370f60ca31f236cbf
(7422717674 bytes, checkpointDuration=12231 ms, finalizationTime=44
ms).
2021-11-13 20:20:27,728 INFO
org.apache.flink.runtime.source.coordinator.SourceCoordinator [] -
Marking checkpoint 78 as completed for source Source: kafka-source ->
input-parser -> wm-gen -> navigps-filter.
2021-11-13 20:29:29,556 INFO
org.apache.flink.runtime.executiongraph.ExecutionGraph [] -
path-filter -> session-window -> (Sink late-data, session-filter ->
enricher -> calculator -> (Sink kafka-sink, Sink
kafka-sink-for-output-stats, filter-mm-failure -> Sink
kafka-sink-for-mm-failure)) (10/64) (f75e736fa49e853d75b60428f30d5ca2)
switched from RUNNING to FAILED on
container_e141_1633577524620_0166_01_000002 @
mobdata-flink-dn22.dakao.io (dataPort=43902).
org.apache.flink.util.FlinkRuntimeException: Failed to send data to
Kafka null with FlinkKafkaInternalProducer{transactionalId='null',
inTransaction=false, closed=false}
at org.apache.flink.connector.kafka.sink.KafkaWriter$WriterCallback.throwException(KafkaWriter.java:402)
~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
at org.apache.flink.connector.kafka.sink.KafkaWriter$WriterCallback.lambda$onCompletion$0(KafkaWriter.java:388)
~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
at org.apache.flink.streaming.runtime.tasks.StreamTaskActionExecutor$1.runThrowing(StreamTaskActionExecutor.java:50)
~[flink-dist_2.11-1.14.0.jar:1.14.0]
at org.apache.flink.streaming.runtime.tasks.mailbox.Mail.run(Mail.java:90)
~[flink-dist_2.11-1.14.0.jar:1.14.0]
at org.apache.flink.streaming.runtime.tasks.mailbox.MailboxProcessor.processMailsNonBlocking(MailboxProcessor.java:353)
~[flink-dist_2.11-1.14.0.jar:1.14.0]
at org.apache.flink.streaming.runtime.tasks.mailbox.MailboxProcessor.processMail(MailboxProcessor.java:317)
~[flink-dist_2.11-1.14.0.jar:1.14.0]
at org.apache.flink.streaming.runtime.tasks.mailbox.MailboxProcessor.runMailboxLoop(MailboxProcessor.java:201)
~[flink-dist_2.11-1.14.0.jar:1.14.0]
at org.apache.flink.streaming.runtime.tasks.StreamTask.runMailboxLoop(StreamTask.java:809)
~[flink-dist_2.11-1.14.0.jar:1.14.0]
at org.apache.flink.streaming.runtime.tasks.StreamTask.invoke(StreamTask.java:761)
~[flink-dist_2.11-1.14.0.jar:1.14.0]
at org.apache.flink.runtime.taskmanager.Task.runWithSystemExitMonitoring(Task.java:958)
~[flink-dist_2.11-1.14.0.jar:1.14.0]
at org.apache.flink.runtime.taskmanager.Task.restoreAndInvoke(Task.java:937)
~[flink-dist_2.11-1.14.0.jar:1.14.0]
at org.apache.flink.runtime.taskmanager.Task.doRun(Task.java:766)
~[flink-dist_2.11-1.14.0.jar:1.14.0]
at org.apache.flink.runtime.taskmanager.Task.run(Task.java:575)
~[flink-dist_2.11-1.14.0.jar:1.14.0]
at java.lang.Thread.run(Thread.java:829) ~[?:?]
Caused by: org.apache.kafka.common.errors.TimeoutException: Failed to
allocate memory within the configured max blocking time 60000 ms.
The other day I faced the similar exception (though it is not from Kafka
producers):
2021-11-11 09:27:08,429 WARN org.apache.hadoop.hdfs.DataStreamer
[] - DataStreamer Exception
java.lang.OutOfMemoryError: Direct buffer memory
at java.nio.Bits.reserveMemory(Bits.java:175) ~[?:?]
at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:118) ~[?:?]
at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:317) ~[?:?]
at sun.nio.ch.Util.getTemporaryDirectBuffer(Util.java:242) ~[?:?]
at sun.nio.ch.IOUtil.write(IOUtil.java:71) ~[?:?]
at sun.nio.ch.IOUtil.write(IOUtil.java:50) ~[?:?]
at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:462) ~[?:?]
at org.apache.hadoop.net.SocketOutputStream$Writer.performIO(SocketOutputStream.java:63)
~[hadoop-common-3.1.1.3.1.4.0-315.jar:?]
at org.apache.hadoop.net.SocketIOWithTimeout.doIO(SocketIOWithTimeout.java:142)
~[hadoop-common-3.1.1.3.1.4.0-315.jar:?]
at org.apache.hadoop.net.SocketOutputStream.write(SocketOutputStream.java:159)
~[hadoop-common-3.1.1.3.1.4.0-315.jar:?]
at org.apache.hadoop.net.SocketOutputStream.write(SocketOutputStream.java:117)
~[hadoop-common-3.1.1.3.1.4.0-315.jar:?]
at java.io.BufferedOutputStream.write(BufferedOutputStream.java:123) ~[?:?]
at java.io.DataOutputStream.write(DataOutputStream.java:107) ~[?:?]
at org.apache.hadoop.hdfs.DFSPacket.writeTo(DFSPacket.java:194)
~[hadoop-hdfs-client-3.1.1.3.1.4.0-315.jar:?]
at org.apache.hadoop.hdfs.DataStreamer.run(DataStreamer.java:774)
[hadoop-hdfs-client-3.1.1.3.1.4.0-315.jar:?]
Best,
Dongwon
On Wed, Nov 10, 2021 at 8:01 PM Dongwon Kim <ea...@gmail.com> wrote:
> Hi Fabian,
>
> 1. Since you already set up PromQL can you also share the JVM memory
>> statics
>> i.e. DirectMemory consumption over time? I would be interested to see
>> whether
>> the consumption is slowly increasing until the OOM happens or if it spikes
>> only during the failing checkpoint.
>
>
> For all TMs:
> [image: image.png]
>
> For the TM:
> [image: image.png]
>
> 2. We suspect that the Kafka Sink is causing the problem. Can you try to
>> run
>> your pipeline with a simple DiscadingSink and see if the error keeps
>> happening?
>> Maybe another component in your pipeline allocates a lot of DirectMemory
>> and
>> only the FlinkKafkaProducer hides the problems because it is the first
>> component
>> hitting the threshold.
>> Another option would be to test the new KafkaSink which was released with
>> 1.14
>> and should replace the FlinkKafkaProducer.
>
>
> I launched a variant of the same pipeline without the problematic sink 26
> hours ago and I'd like to
> share the following graph which might be relevant to your second
> suggestion:
> [image: image.png]
> Note that the vertical dotted line denotes 26 hours after the start of the
> original job. What we can
> observe here is that the amount of direct memory used is
> significantly reduced on the second job
> as a result of only excluding the Kafka sink. I think it could give you an
> idea of running with a DiscardingSink
> (I need to observe for the coming hours whether the same OOM exception
> occurs).
>
> Regarding the new KafkaSink, I need to modify the code and run it. I
> just checked on IntelliJ that
> FlinkKafkaProducer is now deprecated on 1.14. Is it recently deprecated?
> Anyway I'll share
> the result of running the pipeline with the new KafkaSink about 36 hours
> from the start of the jobs
> (as you can see from the above graph, it took around one and a half days
> for the job to get to the point.)
>
> Best,
>
> Dongwon
>
> On Wed, Nov 10, 2021 at 6:13 PM Fabian Paul <fa...@ververica.com>
> wrote:
>
>> Hi Dongwon,
>>
>> Thanks for sharing the logs and the metrics screenshots with us.
>> Unfortunately,
>> I think we need more information to further isolate the problem therefore
>> I have
>> a couple of suggestions.
>>
>> 1. Since you already set up PromQL can you also share the JVM memory
>> statics
>> i.e. DirectMemory consumption over time? I would be interested to see
>> whether
>> the consumption is slowly increasing until the OOM happens or if it spikes
>> only during the failing checkpoint.
>>
>> 2. We suspect that the Kafka Sink is causing the problem. Can you try to
>> run
>> your pipeline with a simple DiscadingSink and see if the error keeps
>> happening?
>> Maybe another component in your pipeline allocates a lot of DirectMemory
>> and
>> only the FlinkKafkaProducer hides the problems because it is the first
>> component
>> hitting the threshold.
>> Another option would be to test the new KafkaSink which was released with
>> 1.14
>> and should replace the FlinkKafkaProducer.
>>
>> Best,
>> Fabian
>
>
Re: how to expose the current in-flight async i/o requests as metrics?
Posted by Dongwon Kim <ea...@gmail.com>.
Hi Fabian,
1. Since you already set up PromQL can you also share the JVM memory statics
> i.e. DirectMemory consumption over time? I would be interested to see
> whether
> the consumption is slowly increasing until the OOM happens or if it spikes
> only during the failing checkpoint.
For all TMs:
[image: image.png]
For the TM:
[image: image.png]
2. We suspect that the Kafka Sink is causing the problem. Can you try to run
> your pipeline with a simple DiscadingSink and see if the error keeps
> happening?
> Maybe another component in your pipeline allocates a lot of DirectMemory
> and
> only the FlinkKafkaProducer hides the problems because it is the first
> component
> hitting the threshold.
> Another option would be to test the new KafkaSink which was released with
> 1.14
> and should replace the FlinkKafkaProducer.
I launched a variant of the same pipeline without the problematic sink 26
hours ago and I'd like to
share the following graph which might be relevant to your second suggestion:
[image: image.png]
Note that the vertical dotted line denotes 26 hours after the start of the
original job. What we can
observe here is that the amount of direct memory used is
significantly reduced on the second job
as a result of only excluding the Kafka sink. I think it could give you an
idea of running with a DiscardingSink
(I need to observe for the coming hours whether the same OOM exception
occurs).
Regarding the new KafkaSink, I need to modify the code and run it. I
just checked on IntelliJ that
FlinkKafkaProducer is now deprecated on 1.14. Is it recently deprecated?
Anyway I'll share
the result of running the pipeline with the new KafkaSink about 36 hours
from the start of the jobs
(as you can see from the above graph, it took around one and a half days
for the job to get to the point.)
Best,
Dongwon
On Wed, Nov 10, 2021 at 6:13 PM Fabian Paul <fa...@ververica.com>
wrote:
> Hi Dongwon,
>
> Thanks for sharing the logs and the metrics screenshots with us.
> Unfortunately,
> I think we need more information to further isolate the problem therefore
> I have
> a couple of suggestions.
>
> 1. Since you already set up PromQL can you also share the JVM memory
> statics
> i.e. DirectMemory consumption over time? I would be interested to see
> whether
> the consumption is slowly increasing until the OOM happens or if it spikes
> only during the failing checkpoint.
>
> 2. We suspect that the Kafka Sink is causing the problem. Can you try to
> run
> your pipeline with a simple DiscadingSink and see if the error keeps
> happening?
> Maybe another component in your pipeline allocates a lot of DirectMemory
> and
> only the FlinkKafkaProducer hides the problems because it is the first
> component
> hitting the threshold.
> Another option would be to test the new KafkaSink which was released with
> 1.14
> and should replace the FlinkKafkaProducer.
>
> Best,
> Fabian
Re: how to expose the current in-flight async i/o requests as
metrics?
Posted by Fabian Paul <fa...@ververica.com>.
Hi Dongwon,
Thanks for sharing the logs and the metrics screenshots with us. Unfortunately,
I think we need more information to further isolate the problem therefore I have
a couple of suggestions.
1. Since you already set up PromQL can you also share the JVM memory statics
i.e. DirectMemory consumption over time? I would be interested to see whether
the consumption is slowly increasing until the OOM happens or if it spikes
only during the failing checkpoint.
2. We suspect that the Kafka Sink is causing the problem. Can you try to run
your pipeline with a simple DiscadingSink and see if the error keeps happening?
Maybe another component in your pipeline allocates a lot of DirectMemory and
only the FlinkKafkaProducer hides the problems because it is the first component
hitting the threshold.
Another option would be to test the new KafkaSink which was released with 1.14
and should replace the FlinkKafkaProducer.
Best,
Fabian
Re: how to expose the current in-flight async i/o requests as metrics?
Posted by Dongwon Kim <ea...@gmail.com>.
A suggestion regarding this issue is for TMs to detect such a OOM and to
let JM know that something goes wrong.
I would be much better if JM let me know that the job was failed due to
OOM, not to ckpt failure (which is the result of the deadlock caused by OOM)
The attached are
- taskmanager_container_e141_1633577524620_0156_01_000019_log where OOM is
shown at the end of the file
- jobmanager.log where JM only tells me that a ckpt attempt is expired
Best,
Dongwon
On Wed, Nov 10, 2021 at 1:37 AM Dongwon Kim <ea...@gmail.com> wrote:
> Hi Piotr,
>
> to me it looks like something deadlocked, maybe due to this OOM error from
>> Kafka, preventing a Task from making any progress.
>
> I totally agree with you. Do you think increasing
> taskmanager-memory-framework-off-heap-size [1] is going to solve this
> problem? I just re-run the job again with a value larger than the default
> one.
>
> To confirm Dongwan you could collecte stack traces while the job is in
>> such a blocked state. Deadlocked Kafka could easily explain those symptoms
>> and it would be visible as an extreme back pressure.
>
> As it took quite a long time for the job to stop, it's not that easy for
> me to collect stack traces of the exact moment.
>
> Another thing to look at would be if the job is making any progress or
>> not at all (via for example numRecordsIn/numRecordsOut metric [1]).
>
> - 13:20:40,601 : Kafka Producer OOM occurs on a TM (which I pasted
> previously)
> - 13:20
> - The problematic subtask of the kafka sink stopped receiving records
> around 13:20
> - PromQL :
> flink_taskmanager_job_task_operator_numRecordsInPerSecond{flink_job="$job_name",
> operator_name="Sink:_kafka_sink_for_mm_failure", subtask_index="59"}
> [image: image.png]
> - 13:24
> - Most tasks' sending records to downstream are mostly peaked out
> around this time
> - PromQL : sum by (operator_name)
> (flink_taskmanager_job_task_operator_numRecordsOutPerSecond{flink_job="$job_name"})
> [image: image.png]
> - 13:25
> - All the other subtasks of the kafka sink stopped receiving records
> - PromQL
> : flink_taskmanager_job_task_operator_numRecordsInPerSecond{flink_job="$job_name",
> operator_name="Sink:_kafka_sink_for_mm_failure", subtask_index!="59"}
> [image: image.png]
>
> If you want to decrease the impact of a backpressure, you should decrease
>> the capacity. Not increase it. The more in-flight records in the system,
>> the more records need to be processed/persisted in aligned/unaligned
>> checkpoints.
>>
>
> Thanks for the tip :)
>
> Best,
>
> Dongwon
>
> [1]
> https://ci.apache.org/projects/flink/flink-docs-master/docs/deployment/config/#taskmanager-memory-framework-off-heap-size
>
>
> On Tue, Nov 9, 2021 at 9:06 PM Piotr Nowojski <pn...@apache.org>
> wrote:
>
>> Hi All,
>>
>> to me it looks like something deadlocked, maybe due to this OOM error
>> from Kafka, preventing a Task from making any progress. To confirm Dongwan
>> you could collecte stack traces while the job is in such a blocked state.
>> Deadlocked Kafka could easily explain those symptoms and it would be
>> visible as an extreme back pressure. Another thing to look at would be if
>> the job is making any progress or not at all (via for example
>> numRecordsIn/numRecordsOut metric [1]).
>>
>> A couple of clarifications.
>>
>> > What I suspect is the capacity of the asynchronous operation because
>> limiting the value can cause back-pressure once the capacity is exhausted
>> [1].
>> > Although I could increase the value (...)
>>
>> If you want to decrease the impact of a backpressure, you should decrease
>> the capacity. Not increase it. The more in-flight records in the system,
>> the more records need to be processed/persisted in aligned/unaligned
>> checkpoints.
>>
>> > As far as I can tell from looking at the code, the async operator is
>> able to checkpoint even if the work-queue is exhausted.
>>
>> Yes and no. If work-queue is full, `AsyncWaitOperator` can be snapshoted,
>> but it can not be blocked inside the `AsyncWaitOperator#processElement`
>> method. For checkpoint to be executed, `AsyncWaitrOperator` must finish
>> processing the current record and return execution to the task thread. If
>> the work-queue is full, `AsyncWaitOperator` will block inside the
>> `AsyncWaitOperator#addToWorkQueue` method until the work-queue will have
>> capacity to accept this new element. If what I suspect is happening here is
>> true, and the job is deadlocked via this Kafka issue, `AsyncWaitOperator`
>> will be blocked indefinitely in this method.
>>
>> Best,
>> Piotrek
>>
>> [1]
>> https://ci.apache.org/projects/flink/flink-docs-release-1.14/docs/ops/metrics/#io
>>
>>
>>
>> wt., 9 lis 2021 o 11:55 Fabian Paul <fa...@ververica.com>
>> napisał(a):
>>
>>> Hi Dongwan,
>>>
>>> Can you maybe share more about the setup and how you use the
>>> AsyncFunction with
>>> the Kafka client?
>>>
>>> As David already pointed out it could be indeed a Kafka bug but it could
>>> also
>>> mean that your defined async function leaks direct memory by not freeing
>>> some
>>> resources.
>>>
>>> We can definitely improve the metrics for the AsyncFunction and expose
>>> the
>>> current queue size as a followup.
>>>
>>> Best,
>>> Fabian
>>
>>
Re: how to expose the current in-flight async i/o requests as metrics?
Posted by Dongwon Kim <ea...@gmail.com>.
Hi Piotr,
to me it looks like something deadlocked, maybe due to this OOM error from
> Kafka, preventing a Task from making any progress.
I totally agree with you. Do you think increasing
taskmanager-memory-framework-off-heap-size [1] is going to solve this
problem? I just re-run the job again with a value larger than the default
one.
To confirm Dongwan you could collecte stack traces while the job is in such
> a blocked state. Deadlocked Kafka could easily explain those symptoms and
> it would be visible as an extreme back pressure.
As it took quite a long time for the job to stop, it's not that easy for me
to collect stack traces of the exact moment.
Another thing to look at would be if the job is making any progress or not
> at all (via for example numRecordsIn/numRecordsOut metric [1]).
- 13:20:40,601 : Kafka Producer OOM occurs on a TM (which I pasted
previously)
- 13:20
- The problematic subtask of the kafka sink stopped receiving records
around 13:20
- PromQL :
flink_taskmanager_job_task_operator_numRecordsInPerSecond{flink_job="$job_name",
operator_name="Sink:_kafka_sink_for_mm_failure", subtask_index="59"}
[image: image.png]
- 13:24
- Most tasks' sending records to downstream are mostly peaked out
around this time
- PromQL : sum by (operator_name)
(flink_taskmanager_job_task_operator_numRecordsOutPerSecond{flink_job="$job_name"})
[image: image.png]
- 13:25
- All the other subtasks of the kafka sink stopped receiving records
- PromQL
: flink_taskmanager_job_task_operator_numRecordsInPerSecond{flink_job="$job_name",
operator_name="Sink:_kafka_sink_for_mm_failure", subtask_index!="59"}
[image: image.png]
If you want to decrease the impact of a backpressure, you should decrease
> the capacity. Not increase it. The more in-flight records in the system,
> the more records need to be processed/persisted in aligned/unaligned
> checkpoints.
>
Thanks for the tip :)
Best,
Dongwon
[1]
https://ci.apache.org/projects/flink/flink-docs-master/docs/deployment/config/#taskmanager-memory-framework-off-heap-size
On Tue, Nov 9, 2021 at 9:06 PM Piotr Nowojski <pn...@apache.org> wrote:
> Hi All,
>
> to me it looks like something deadlocked, maybe due to this OOM error from
> Kafka, preventing a Task from making any progress. To confirm Dongwan you
> could collecte stack traces while the job is in such a blocked state.
> Deadlocked Kafka could easily explain those symptoms and it would be
> visible as an extreme back pressure. Another thing to look at would be if
> the job is making any progress or not at all (via for example
> numRecordsIn/numRecordsOut metric [1]).
>
> A couple of clarifications.
>
> > What I suspect is the capacity of the asynchronous operation because
> limiting the value can cause back-pressure once the capacity is exhausted
> [1].
> > Although I could increase the value (...)
>
> If you want to decrease the impact of a backpressure, you should decrease
> the capacity. Not increase it. The more in-flight records in the system,
> the more records need to be processed/persisted in aligned/unaligned
> checkpoints.
>
> > As far as I can tell from looking at the code, the async operator is
> able to checkpoint even if the work-queue is exhausted.
>
> Yes and no. If work-queue is full, `AsyncWaitOperator` can be snapshoted,
> but it can not be blocked inside the `AsyncWaitOperator#processElement`
> method. For checkpoint to be executed, `AsyncWaitrOperator` must finish
> processing the current record and return execution to the task thread. If
> the work-queue is full, `AsyncWaitOperator` will block inside the
> `AsyncWaitOperator#addToWorkQueue` method until the work-queue will have
> capacity to accept this new element. If what I suspect is happening here is
> true, and the job is deadlocked via this Kafka issue, `AsyncWaitOperator`
> will be blocked indefinitely in this method.
>
> Best,
> Piotrek
>
> [1]
> https://ci.apache.org/projects/flink/flink-docs-release-1.14/docs/ops/metrics/#io
>
>
>
> wt., 9 lis 2021 o 11:55 Fabian Paul <fa...@ververica.com> napisał(a):
>
>> Hi Dongwan,
>>
>> Can you maybe share more about the setup and how you use the
>> AsyncFunction with
>> the Kafka client?
>>
>> As David already pointed out it could be indeed a Kafka bug but it could
>> also
>> mean that your defined async function leaks direct memory by not freeing
>> some
>> resources.
>>
>> We can definitely improve the metrics for the AsyncFunction and expose the
>> current queue size as a followup.
>>
>> Best,
>> Fabian
>
>
Re: how to expose the current in-flight async i/o requests as metrics?
Posted by Piotr Nowojski <pn...@apache.org>.
Hi All,
to me it looks like something deadlocked, maybe due to this OOM error from
Kafka, preventing a Task from making any progress. To confirm Dongwan you
could collecte stack traces while the job is in such a blocked state.
Deadlocked Kafka could easily explain those symptoms and it would be
visible as an extreme back pressure. Another thing to look at would be if
the job is making any progress or not at all (via for example
numRecordsIn/numRecordsOut metric [1]).
A couple of clarifications.
> What I suspect is the capacity of the asynchronous operation because
limiting the value can cause back-pressure once the capacity is exhausted
[1].
> Although I could increase the value (...)
If you want to decrease the impact of a backpressure, you should decrease
the capacity. Not increase it. The more in-flight records in the system,
the more records need to be processed/persisted in aligned/unaligned
checkpoints.
> As far as I can tell from looking at the code, the async operator is able
to checkpoint even if the work-queue is exhausted.
Yes and no. If work-queue is full, `AsyncWaitOperator` can be snapshoted,
but it can not be blocked inside the `AsyncWaitOperator#processElement`
method. For checkpoint to be executed, `AsyncWaitrOperator` must finish
processing the current record and return execution to the task thread. If
the work-queue is full, `AsyncWaitOperator` will block inside the
`AsyncWaitOperator#addToWorkQueue` method until the work-queue will have
capacity to accept this new element. If what I suspect is happening here is
true, and the job is deadlocked via this Kafka issue, `AsyncWaitOperator`
will be blocked indefinitely in this method.
Best,
Piotrek
[1]
https://ci.apache.org/projects/flink/flink-docs-release-1.14/docs/ops/metrics/#io
wt., 9 lis 2021 o 11:55 Fabian Paul <fa...@ververica.com> napisał(a):
> Hi Dongwan,
>
> Can you maybe share more about the setup and how you use the AsyncFunction
> with
> the Kafka client?
>
> As David already pointed out it could be indeed a Kafka bug but it could
> also
> mean that your defined async function leaks direct memory by not freeing
> some
> resources.
>
> We can definitely improve the metrics for the AsyncFunction and expose the
> current queue size as a followup.
>
> Best,
> Fabian
Re: how to expose the current in-flight async i/o requests as
metrics?
Posted by Fabian Paul <fa...@ververica.com>.
Hi Dongwan,
Can you maybe share more about the setup and how you use the AsyncFunction with
the Kafka client?
As David already pointed out it could be indeed a Kafka bug but it could also
mean that your defined async function leaks direct memory by not freeing some
resources.
We can definitely improve the metrics for the AsyncFunction and expose the
current queue size as a followup.
Best,
Fabian
Re: how to expose the current in-flight async i/o requests as metrics?
Posted by Dongwon Kim <ea...@gmail.com>.
Hi Jun,
Did you override AsyncFunction#timeout()? If so, did you call
> resultFuture.complete()/completeExceptionally() in your override? Not
> calling them can result in checkpoint timeout.
No, I've only called resultFuture.complete() in AsyncFunction.asyncInvoke()
and didn't know much about AsyncFunction.timeout(). However, looking at
the default implementation of AsyncFunction.timeout(), I'd rather get the
timeout exception as my streaming pipeline is going to be fail-fast which
is what I prefer the most.
I think I understand what you are concerned about but, as I wrote in the
reply to David, the problem seems to be the kafka sink which I recently
added to the pipeline in order to write large records (~10MB) for the
debugging purpose.
Anyway thanks a lot for letting me know the possibility of overriding
AsyncFunction.timeout().
Best,
Dongwon
On Tue, Nov 9, 2021 at 5:53 PM Jun Qin <qi...@gmail.com> wrote:
> Hi Dongwon
>
> Did you override AsyncFunction#timeout()? If so, did you call
> resultFuture.complete()/completeExceptionally() in your override? Not
> calling them can result in checkpoint timeout.
>
> Thanks
> Jun
>
>
> On Nov 9, 2021, at 7:37 AM, Dongwon Kim <ea...@gmail.com> wrote:
>
> Hi David,
>
> There are currently no metrics for the async work-queue size (you should
>> be able to see the queue stats with debug logs enabled though [1]).
>
> Thanks for the input but scraping DEBUG messages into, for example,
> ElasticSearch for monitoring on Grafana is not possible in my current
> environment.
> I just defined two counters in RichAsyncFunction for tracking # sent
> requests and # finished/failed requests, respectively, and used the two
> counters to calculate the inflight requests from Prometheus.
>
> As far as I can tell from looking at the code, the async operator is able
>> to checkpoint even if the work-queue is exhausted.
>
> Oh, I didn't know that! As you pointed out and I'm going to explain below,
> the async operator might not be the source of the problem.
>
> I just hit the same situation and found that
> - # of inflight records are zero when the backpressure is getting high
> - A taskmanager complains the following error message around the time when
> the backpressure is getting high (all the others don't do):
>
>> 2021-11-09 13:20:40,601 ERROR org.apache.kafka.common.utils.KafkaThread
>> [] - Uncaught exception in thread
>> 'kafka-producer-network-thread | producer-8':
>> java.lang.OutOfMemoryError: Direct buffer memory
>> at java.nio.Bits.reserveMemory(Bits.java:175) ~[?:?]
>> at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:118)
>> ~[?:?]
>> at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:317) ~[?:?]
>> at sun.nio.ch.Util.getTemporaryDirectBuffer(Util.java:242) ~[?:?]
>> at sun.nio.ch.IOUtil.write(IOUtil.java:164) ~[?:?]
>> at sun.nio.ch.IOUtil.write(IOUtil.java:130) ~[?:?]
>> at
>> sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:493) ~[?:?]
>> at java.nio.channels.SocketChannel.write(SocketChannel.java:507)
>> ~[?:?]
>> at
>> org.apache.kafka.common.network.PlaintextTransportLayer.write(PlaintextTransportLayer.java:152)
>> ~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
>> at
>> org.apache.kafka.common.network.ByteBufferSend.writeTo(ByteBufferSend.java:60)
>> ~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
>> at
>> org.apache.kafka.common.network.KafkaChannel.send(KafkaChannel.java:429)
>> ~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
>> at
>> org.apache.kafka.common.network.KafkaChannel.write(KafkaChannel.java:399)
>> ~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
>> at
>> org.apache.kafka.common.network.Selector.pollSelectionKeys(Selector.java:589)
>> ~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
>> at
>> org.apache.kafka.common.network.Selector.poll(Selector.java:483)
>> ~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
>> at
>> org.apache.kafka.clients.NetworkClient.poll(NetworkClient.java:547)
>> ~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
>> at
>> org.apache.kafka.clients.producer.internals.Sender.runOnce(Sender.java:335)
>> ~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
>> at
>> org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:244)
>> ~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
>> at java.lang.Thread.run(Thread.java:829) [?:?]
>>
>
> Can it be the reason why my pipeline is stalled and ends up with the
> checkout timeout? I guess all the upstream tasks might fail to send data to
> the failed kafka producer and records are stacking up in buffers, which
> could result in the back-pressure. If so, is there no mechanism in Flink to
> detect such an error and send it to the job manager for debugging purposes?
>
> Best,
>
> Dongwon
>
>
> On Mon, Nov 8, 2021 at 9:21 PM David Morávek <dm...@apache.org> wrote:
>
>> Hi Dongwon,
>>
>> There are currently no metrics for the async work-queue size (you should
>> be able to see the queue stats with debug logs enabled though [1]). As far
>> as I can tell from looking at the code, the async operator is able to
>> checkpoint even if the work-queue is exhausted.
>>
>> Arvid can you please validate the above? (the checkpoints not being
>> blocked by the work queue part)
>>
>> [1]
>> https://github.com/apache/flink/blob/release-1.14.0/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/operators/async/queue/OrderedStreamElementQueue.java#L109
>>
>> Best,
>> D.
>>
>> On Sun, Nov 7, 2021 at 10:41 AM Dongwon Kim <ea...@gmail.com>
>> wrote:
>>
>>> Hi community,
>>>
>>> While using Flink's async i/o for interacting with an external system, I
>>> got the following exception:
>>>
>>> 2021-11-06 10:38:35,270 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Triggering checkpoint 54 (type=CHECKPOINT) @ 1636162715262 for job f168a44ea33198cd71783824d49f9554.
>>> 2021-11-06 10:38:47,031 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Completed checkpoint 54 for job f168a44ea33198cd71783824d49f9554 (11930992707 bytes, checkpointDuration=11722 ms, finalizationTime=47 ms).
>>> 2021-11-06 10:58:35,270 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Triggering checkpoint 55 (type=CHECKPOINT) @ 1636163915262 for job f168a44ea33198cd71783824d49f9554.
>>> 2021-11-06 11:08:35,271 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Checkpoint 55 of job f168a44ea33198cd71783824d49f9554 expired before completing.
>>> 2021-11-06 11:08:35,287 INFO org.apache.flink.runtime.jobmaster.JobMaster [] - Trying to recover from a global failure.
>>>
>>>
>>> - FYI, I'm using 1.14.0 and enabled unaligned checkpointing and buffer
>>> debloating
>>> - the 55th ckpt failed to complete within 10 mins (which is the value of
>>> execution.checkpointing.timeout)
>>> - the below graph shows that backpressure skyrocketed around the time
>>> the 55th ckpt began
>>> <image.png>
>>>
>>> What I suspect is the capacity of the asynchronous operation because
>>> limiting the value can cause back-pressure once the capacity is exhausted
>>> [1].
>>>
>>> Although I could increase the value, I want to monitor the current
>>> in-flight async i/o requests like the above back-pressure graph on Grafana.
>>> [2] does not introduce any system metric specific to async i/o.
>>>
>>> Best,
>>>
>>> Dongwon
>>>
>>> [1]
>>> https://ci.apache.org/projects/flink/flink-docs-master/docs/dev/datastream/operators/asyncio/#async-io-api
>>> [2]
>>> https://ci.apache.org/projects/flink/flink-docs-master/docs/ops/metrics/#system-metrics
>>>
>>>
>>>
>
Re: how to expose the current in-flight async i/o requests as
metrics?
Posted by Jun Qin <qi...@gmail.com>.
Hi Dongwon
Did you override AsyncFunction#timeout()? If so, did you call resultFuture.complete()/completeExceptionally() in your override? Not calling them can result in checkpoint timeout.
Thanks
Jun
> On Nov 9, 2021, at 7:37 AM, Dongwon Kim <ea...@gmail.com> wrote:
>
> Hi David,
>
> There are currently no metrics for the async work-queue size (you should be able to see the queue stats with debug logs enabled though [1]).
> Thanks for the input but scraping DEBUG messages into, for example, ElasticSearch for monitoring on Grafana is not possible in my current environment.
> I just defined two counters in RichAsyncFunction for tracking # sent requests and # finished/failed requests, respectively, and used the two counters to calculate the inflight requests from Prometheus.
>
> As far as I can tell from looking at the code, the async operator is able to checkpoint even if the work-queue is exhausted.
> Oh, I didn't know that! As you pointed out and I'm going to explain below, the async operator might not be the source of the problem.
>
> I just hit the same situation and found that
> - # of inflight records are zero when the backpressure is getting high
> - A taskmanager complains the following error message around the time when the backpressure is getting high (all the others don't do):
> 2021-11-09 13:20:40,601 ERROR org.apache.kafka.common.utils.KafkaThread [] - Uncaught exception in thread 'kafka-producer-network-thread | producer-8':
> java.lang.OutOfMemoryError: Direct buffer memory
> at java.nio.Bits.reserveMemory(Bits.java:175) ~[?:?]
> at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:118) ~[?:?]
> at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:317) ~[?:?]
> at sun.nio.ch.Util.getTemporaryDirectBuffer(Util.java:242) ~[?:?]
> at sun.nio.ch.IOUtil.write(IOUtil.java:164) ~[?:?]
> at sun.nio.ch.IOUtil.write(IOUtil.java:130) ~[?:?]
> at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:493) ~[?:?]
> at java.nio.channels.SocketChannel.write(SocketChannel.java:507) ~[?:?]
> at org.apache.kafka.common.network.PlaintextTransportLayer.write(PlaintextTransportLayer.java:152) ~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
> at org.apache.kafka.common.network.ByteBufferSend.writeTo(ByteBufferSend.java:60) ~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
> at org.apache.kafka.common.network.KafkaChannel.send(KafkaChannel.java:429) ~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
> at org.apache.kafka.common.network.KafkaChannel.write(KafkaChannel.java:399) ~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
> at org.apache.kafka.common.network.Selector.pollSelectionKeys(Selector.java:589) ~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
> at org.apache.kafka.common.network.Selector.poll(Selector.java:483) ~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
> at org.apache.kafka.clients.NetworkClient.poll(NetworkClient.java:547) ~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
> at org.apache.kafka.clients.producer.internals.Sender.runOnce(Sender.java:335) ~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
> at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:244) ~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
> at java.lang.Thread.run(Thread.java:829) [?:?]
>
> Can it be the reason why my pipeline is stalled and ends up with the checkout timeout? I guess all the upstream tasks might fail to send data to the failed kafka producer and records are stacking up in buffers, which could result in the back-pressure. If so, is there no mechanism in Flink to detect such an error and send it to the job manager for debugging purposes?
>
> Best,
>
> Dongwon
>
>
> On Mon, Nov 8, 2021 at 9:21 PM David Morávek <dmvk@apache.org <ma...@apache.org>> wrote:
> Hi Dongwon,
>
> There are currently no metrics for the async work-queue size (you should be able to see the queue stats with debug logs enabled though [1]). As far as I can tell from looking at the code, the async operator is able to checkpoint even if the work-queue is exhausted.
>
> Arvid can you please validate the above? (the checkpoints not being blocked by the work queue part)
>
> [1] https://github.com/apache/flink/blob/release-1.14.0/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/operators/async/queue/OrderedStreamElementQueue.java#L109 <https://github.com/apache/flink/blob/release-1.14.0/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/operators/async/queue/OrderedStreamElementQueue.java#L109>
>
> Best,
> D.
>
> On Sun, Nov 7, 2021 at 10:41 AM Dongwon Kim <eastcirclek@gmail.com <ma...@gmail.com>> wrote:
> Hi community,
>
> While using Flink's async i/o for interacting with an external system, I got the following exception:
>
> 2021-11-06 10:38:35,270 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Triggering checkpoint 54 (type=CHECKPOINT) @ 1636162715262 for job f168a44ea33198cd71783824d49f9554.
> 2021-11-06 10:38:47,031 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Completed checkpoint 54 for job f168a44ea33198cd71783824d49f9554 (11930992707 bytes, checkpointDuration=11722 ms, finalizationTime=47 ms).
> 2021-11-06 10:58:35,270 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Triggering checkpoint 55 (type=CHECKPOINT) @ 1636163915262 for job f168a44ea33198cd71783824d49f9554.
> 2021-11-06 11:08:35,271 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Checkpoint 55 of job f168a44ea33198cd71783824d49f9554 expired before completing.
> 2021-11-06 11:08:35,287 INFO org.apache.flink.runtime.jobmaster.JobMaster [] - Trying to recover from a global failure.
>
> - FYI, I'm using 1.14.0 and enabled unaligned checkpointing and buffer debloating
> - the 55th ckpt failed to complete within 10 mins (which is the value of execution.checkpointing.timeout)
> - the below graph shows that backpressure skyrocketed around the time the 55th ckpt began
> <image.png>
>
> What I suspect is the capacity of the asynchronous operation because limiting the value can cause back-pressure once the capacity is exhausted [1].
>
> Although I could increase the value, I want to monitor the current in-flight async i/o requests like the above back-pressure graph on Grafana.
> [2] does not introduce any system metric specific to async i/o.
>
> Best,
>
> Dongwon
>
> [1] https://ci.apache.org/projects/flink/flink-docs-master/docs/dev/datastream/operators/asyncio/#async-io-api <https://ci.apache.org/projects/flink/flink-docs-master/docs/dev/datastream/operators/asyncio/#async-io-api>
> [2] https://ci.apache.org/projects/flink/flink-docs-master/docs/ops/metrics/#system-metrics <https://ci.apache.org/projects/flink/flink-docs-master/docs/ops/metrics/#system-metrics>
>
>
Re: how to expose the current in-flight async i/o requests as metrics?
Posted by David Morávek <dm...@apache.org>.
This is definitely a bug on Kafka side, because they're not handling
uncaught exceptions properly [1]. I don't think there is much we can do on
the Flink side here, because we're not able to override factory for the
Kafka IO thread :/
[1] https://issues.apache.org/jira/browse/KAFKA-4228
On Tue, Nov 9, 2021 at 7:38 AM Dongwon Kim <ea...@gmail.com> wrote:
> Hi David,
>
> There are currently no metrics for the async work-queue size (you should
>> be able to see the queue stats with debug logs enabled though [1]).
>
> Thanks for the input but scraping DEBUG messages into, for example,
> ElasticSearch for monitoring on Grafana is not possible in my current
> environment.
> I just defined two counters in RichAsyncFunction for tracking # sent
> requests and # finished/failed requests, respectively, and used the two
> counters to calculate the inflight requests from Prometheus.
>
> As far as I can tell from looking at the code, the async operator is able
>> to checkpoint even if the work-queue is exhausted.
>
> Oh, I didn't know that! As you pointed out and I'm going to explain below,
> the async operator might not be the source of the problem.
>
> I just hit the same situation and found that
> - # of inflight records are zero when the backpressure is getting high
> - A taskmanager complains the following error message around the time when
> the backpressure is getting high (all the others don't do):
>
>> 2021-11-09 13:20:40,601 ERROR org.apache.kafka.common.utils.KafkaThread
>> [] - Uncaught exception in thread
>> 'kafka-producer-network-thread | producer-8':
>>
>> java.lang.OutOfMemoryError: Direct buffer memory
>>
>> at java.nio.Bits.reserveMemory(Bits.java:175) ~[?:?]
>>
>> at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:118)
>> ~[?:?]
>>
>> at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:317) ~[?:?]
>>
>> at sun.nio.ch.Util.getTemporaryDirectBuffer(Util.java:242) ~[?:?]
>>
>> at sun.nio.ch.IOUtil.write(IOUtil.java:164) ~[?:?]
>>
>> at sun.nio.ch.IOUtil.write(IOUtil.java:130) ~[?:?]
>>
>> at
>> sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:493) ~[?:?]
>>
>> at java.nio.channels.SocketChannel.write(SocketChannel.java:507)
>> ~[?:?]
>>
>> at
>> org.apache.kafka.common.network.PlaintextTransportLayer.write(PlaintextTransportLayer.java:152)
>> ~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
>>
>> at
>> org.apache.kafka.common.network.ByteBufferSend.writeTo(ByteBufferSend.java:60)
>> ~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
>>
>> at
>> org.apache.kafka.common.network.KafkaChannel.send(KafkaChannel.java:429)
>> ~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
>>
>> at
>> org.apache.kafka.common.network.KafkaChannel.write(KafkaChannel.java:399)
>> ~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
>>
>> at
>> org.apache.kafka.common.network.Selector.pollSelectionKeys(Selector.java:589)
>> ~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
>>
>> at
>> org.apache.kafka.common.network.Selector.poll(Selector.java:483)
>> ~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
>>
>> at
>> org.apache.kafka.clients.NetworkClient.poll(NetworkClient.java:547)
>> ~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
>>
>> at
>> org.apache.kafka.clients.producer.internals.Sender.runOnce(Sender.java:335)
>> ~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
>>
>> at
>> org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:244)
>> ~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
>>
>> at java.lang.Thread.run(Thread.java:829) [?:?]
>>
>
> Can it be the reason why my pipeline is stalled and ends up with the
> checkout timeout? I guess all the upstream tasks might fail to send data to
> the failed kafka producer and records are stacking up in buffers, which
> could result in the back-pressure. If so, is there no mechanism in Flink to
> detect such an error and send it to the job manager for debugging purposes?
>
> Best,
>
> Dongwon
>
>
> On Mon, Nov 8, 2021 at 9:21 PM David Morávek <dm...@apache.org> wrote:
>
>> Hi Dongwon,
>>
>> There are currently no metrics for the async work-queue size (you should
>> be able to see the queue stats with debug logs enabled though [1]). As far
>> as I can tell from looking at the code, the async operator is able to
>> checkpoint even if the work-queue is exhausted.
>>
>> Arvid can you please validate the above? (the checkpoints not being
>> blocked by the work queue part)
>>
>> [1]
>> https://github.com/apache/flink/blob/release-1.14.0/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/operators/async/queue/OrderedStreamElementQueue.java#L109
>>
>> Best,
>> D.
>>
>> On Sun, Nov 7, 2021 at 10:41 AM Dongwon Kim <ea...@gmail.com>
>> wrote:
>>
>>> Hi community,
>>>
>>> While using Flink's async i/o for interacting with an external system, I
>>> got the following exception:
>>>
>>> 2021-11-06 10:38:35,270 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Triggering checkpoint 54 (type=CHECKPOINT) @ 1636162715262 for job f168a44ea33198cd71783824d49f9554.
>>> 2021-11-06 10:38:47,031 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Completed checkpoint 54 for job f168a44ea33198cd71783824d49f9554 (11930992707 bytes, checkpointDuration=11722 ms, finalizationTime=47 ms).
>>> 2021-11-06 10:58:35,270 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Triggering checkpoint 55 (type=CHECKPOINT) @ 1636163915262 for job f168a44ea33198cd71783824d49f9554.
>>> 2021-11-06 11:08:35,271 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Checkpoint 55 of job f168a44ea33198cd71783824d49f9554 expired before completing.
>>> 2021-11-06 11:08:35,287 INFO org.apache.flink.runtime.jobmaster.JobMaster [] - Trying to recover from a global failure.
>>>
>>>
>>> - FYI, I'm using 1.14.0 and enabled unaligned checkpointing and buffer
>>> debloating
>>> - the 55th ckpt failed to complete within 10 mins (which is the value of
>>> execution.checkpointing.timeout)
>>> - the below graph shows that backpressure skyrocketed around the time
>>> the 55th ckpt began
>>> [image: image.png]
>>>
>>> What I suspect is the capacity of the asynchronous operation because
>>> limiting the value can cause back-pressure once the capacity is exhausted
>>> [1].
>>>
>>> Although I could increase the value, I want to monitor the current
>>> in-flight async i/o requests like the above back-pressure graph on Grafana.
>>> [2] does not introduce any system metric specific to async i/o.
>>>
>>> Best,
>>>
>>> Dongwon
>>>
>>> [1]
>>> https://ci.apache.org/projects/flink/flink-docs-master/docs/dev/datastream/operators/asyncio/#async-io-api
>>> [2]
>>> https://ci.apache.org/projects/flink/flink-docs-master/docs/ops/metrics/#system-metrics
>>>
>>>
>>>
Re: how to expose the current in-flight async i/o requests as metrics?
Posted by Dongwon Kim <ea...@gmail.com>.
Hi David,
There are currently no metrics for the async work-queue size (you should be
> able to see the queue stats with debug logs enabled though [1]).
Thanks for the input but scraping DEBUG messages into, for example,
ElasticSearch for monitoring on Grafana is not possible in my current
environment.
I just defined two counters in RichAsyncFunction for tracking # sent
requests and # finished/failed requests, respectively, and used the two
counters to calculate the inflight requests from Prometheus.
As far as I can tell from looking at the code, the async operator is able
> to checkpoint even if the work-queue is exhausted.
Oh, I didn't know that! As you pointed out and I'm going to explain below,
the async operator might not be the source of the problem.
I just hit the same situation and found that
- # of inflight records are zero when the backpressure is getting high
- A taskmanager complains the following error message around the time when
the backpressure is getting high (all the others don't do):
> 2021-11-09 13:20:40,601 ERROR org.apache.kafka.common.utils.KafkaThread
> [] - Uncaught exception in thread
> 'kafka-producer-network-thread | producer-8':
>
> java.lang.OutOfMemoryError: Direct buffer memory
>
> at java.nio.Bits.reserveMemory(Bits.java:175) ~[?:?]
>
> at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:118)
> ~[?:?]
>
> at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:317) ~[?:?]
>
> at sun.nio.ch.Util.getTemporaryDirectBuffer(Util.java:242) ~[?:?]
>
> at sun.nio.ch.IOUtil.write(IOUtil.java:164) ~[?:?]
>
> at sun.nio.ch.IOUtil.write(IOUtil.java:130) ~[?:?]
>
> at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:493)
> ~[?:?]
>
> at java.nio.channels.SocketChannel.write(SocketChannel.java:507)
> ~[?:?]
>
> at
> org.apache.kafka.common.network.PlaintextTransportLayer.write(PlaintextTransportLayer.java:152)
> ~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
>
> at
> org.apache.kafka.common.network.ByteBufferSend.writeTo(ByteBufferSend.java:60)
> ~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
>
> at
> org.apache.kafka.common.network.KafkaChannel.send(KafkaChannel.java:429)
> ~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
>
> at
> org.apache.kafka.common.network.KafkaChannel.write(KafkaChannel.java:399)
> ~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
>
> at
> org.apache.kafka.common.network.Selector.pollSelectionKeys(Selector.java:589)
> ~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
>
> at
> org.apache.kafka.common.network.Selector.poll(Selector.java:483)
> ~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
>
> at
> org.apache.kafka.clients.NetworkClient.poll(NetworkClient.java:547)
> ~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
>
> at
> org.apache.kafka.clients.producer.internals.Sender.runOnce(Sender.java:335)
> ~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
>
> at
> org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:244)
> ~[drivinghabit-stream-calculator-2.0-SNAPSHOT.jar:?]
>
> at java.lang.Thread.run(Thread.java:829) [?:?]
>
Can it be the reason why my pipeline is stalled and ends up with the
checkout timeout? I guess all the upstream tasks might fail to send data to
the failed kafka producer and records are stacking up in buffers, which
could result in the back-pressure. If so, is there no mechanism in Flink to
detect such an error and send it to the job manager for debugging purposes?
Best,
Dongwon
On Mon, Nov 8, 2021 at 9:21 PM David Morávek <dm...@apache.org> wrote:
> Hi Dongwon,
>
> There are currently no metrics for the async work-queue size (you should
> be able to see the queue stats with debug logs enabled though [1]). As far
> as I can tell from looking at the code, the async operator is able to
> checkpoint even if the work-queue is exhausted.
>
> Arvid can you please validate the above? (the checkpoints not being
> blocked by the work queue part)
>
> [1]
> https://github.com/apache/flink/blob/release-1.14.0/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/operators/async/queue/OrderedStreamElementQueue.java#L109
>
> Best,
> D.
>
> On Sun, Nov 7, 2021 at 10:41 AM Dongwon Kim <ea...@gmail.com> wrote:
>
>> Hi community,
>>
>> While using Flink's async i/o for interacting with an external system, I
>> got the following exception:
>>
>> 2021-11-06 10:38:35,270 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Triggering checkpoint 54 (type=CHECKPOINT) @ 1636162715262 for job f168a44ea33198cd71783824d49f9554.
>> 2021-11-06 10:38:47,031 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Completed checkpoint 54 for job f168a44ea33198cd71783824d49f9554 (11930992707 bytes, checkpointDuration=11722 ms, finalizationTime=47 ms).
>> 2021-11-06 10:58:35,270 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Triggering checkpoint 55 (type=CHECKPOINT) @ 1636163915262 for job f168a44ea33198cd71783824d49f9554.
>> 2021-11-06 11:08:35,271 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Checkpoint 55 of job f168a44ea33198cd71783824d49f9554 expired before completing.
>> 2021-11-06 11:08:35,287 INFO org.apache.flink.runtime.jobmaster.JobMaster [] - Trying to recover from a global failure.
>>
>>
>> - FYI, I'm using 1.14.0 and enabled unaligned checkpointing and buffer
>> debloating
>> - the 55th ckpt failed to complete within 10 mins (which is the value of
>> execution.checkpointing.timeout)
>> - the below graph shows that backpressure skyrocketed around the time the
>> 55th ckpt began
>> [image: image.png]
>>
>> What I suspect is the capacity of the asynchronous operation because
>> limiting the value can cause back-pressure once the capacity is exhausted
>> [1].
>>
>> Although I could increase the value, I want to monitor the current
>> in-flight async i/o requests like the above back-pressure graph on Grafana.
>> [2] does not introduce any system metric specific to async i/o.
>>
>> Best,
>>
>> Dongwon
>>
>> [1]
>> https://ci.apache.org/projects/flink/flink-docs-master/docs/dev/datastream/operators/asyncio/#async-io-api
>> [2]
>> https://ci.apache.org/projects/flink/flink-docs-master/docs/ops/metrics/#system-metrics
>>
>>
>>
Re: how to expose the current in-flight async i/o requests as metrics?
Posted by David Morávek <dm...@apache.org>.
Hi Dongwon,
There are currently no metrics for the async work-queue size (you should be
able to see the queue stats with debug logs enabled though [1]). As far as
I can tell from looking at the code, the async operator is able to
checkpoint even if the work-queue is exhausted.
Arvid can you please validate the above? (the checkpoints not being blocked
by the work queue part)
[1]
https://github.com/apache/flink/blob/release-1.14.0/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/operators/async/queue/OrderedStreamElementQueue.java#L109
Best,
D.
On Sun, Nov 7, 2021 at 10:41 AM Dongwon Kim <ea...@gmail.com> wrote:
> Hi community,
>
> While using Flink's async i/o for interacting with an external system, I
> got the following exception:
>
> 2021-11-06 10:38:35,270 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Triggering checkpoint 54 (type=CHECKPOINT) @ 1636162715262 for job f168a44ea33198cd71783824d49f9554.
> 2021-11-06 10:38:47,031 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Completed checkpoint 54 for job f168a44ea33198cd71783824d49f9554 (11930992707 bytes, checkpointDuration=11722 ms, finalizationTime=47 ms).
> 2021-11-06 10:58:35,270 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Triggering checkpoint 55 (type=CHECKPOINT) @ 1636163915262 for job f168a44ea33198cd71783824d49f9554.
> 2021-11-06 11:08:35,271 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Checkpoint 55 of job f168a44ea33198cd71783824d49f9554 expired before completing.
> 2021-11-06 11:08:35,287 INFO org.apache.flink.runtime.jobmaster.JobMaster [] - Trying to recover from a global failure.
>
>
> - FYI, I'm using 1.14.0 and enabled unaligned checkpointing and buffer
> debloating
> - the 55th ckpt failed to complete within 10 mins (which is the value of
> execution.checkpointing.timeout)
> - the below graph shows that backpressure skyrocketed around the time the
> 55th ckpt began
> [image: image.png]
>
> What I suspect is the capacity of the asynchronous operation because
> limiting the value can cause back-pressure once the capacity is exhausted
> [1].
>
> Although I could increase the value, I want to monitor the current
> in-flight async i/o requests like the above back-pressure graph on Grafana.
> [2] does not introduce any system metric specific to async i/o.
>
> Best,
>
> Dongwon
>
> [1]
> https://ci.apache.org/projects/flink/flink-docs-master/docs/dev/datastream/operators/asyncio/#async-io-api
> [2]
> https://ci.apache.org/projects/flink/flink-docs-master/docs/ops/metrics/#system-metrics
>
>
>