Initially when job starts there is Record sent/rec...
# troubleshooting
s
Initially when job starts there is Record sent/received count available but then duration gets reset to 0 and Record sent/received count and other metrics on flink dashboard shows as zero though records are being processed ? My Job details : https://stackoverflow.com/questions/78097038/apache-flink-pubsub-connector-slow-processing
Only exception I see is
Copy code
2024-03-05 21:01:52
org.apache.flink.util.FlinkRuntimeException: Exceeded checkpoint tolerable failure threshold. The latest checkpoint failed due to Asynchronous task checkpoint failed., view the Checkpoint History tab or the Job Manager log to find out why continuous checkpoints failed.
	at org.apache.flink.runtime.checkpoint.CheckpointFailureManager.checkFailureAgainstCounter(CheckpointFailureManager.java:212)
	at org.apache.flink.runtime.checkpoint.CheckpointFailureManager.handleTaskLevelCheckpointException(CheckpointFailureManager.java:191)
	at org.apache.flink.runtime.checkpoint.CheckpointFailureManager.handleCheckpointException(CheckpointFailureManager.java:124)
	at org.apache.flink.runtime.checkpoint.CheckpointCoordinator.abortPendingCheckpoint(CheckpointCoordinator.java:2151)
	at org.apache.flink.runtime.checkpoint.CheckpointCoordinator.receiveDeclineMessage(CheckpointCoordinator.java:1100)
	at org.apache.flink.runtime.scheduler.ExecutionGraphHandler.lambda$declineCheckpoint$2(ExecutionGraphHandler.java:103)
	at org.apache.flink.runtime.scheduler.ExecutionGraphHandler.lambda$processCheckpointCoordinatorMessage$3(ExecutionGraphHandler.java:119)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)
l
@Shubham Jain could you please address the above? Failing checkpointing prevents the correct functioning of a Flink job. Let's try to solve that issue and see if the job goes back to normality. As a starting point, can you disable checkpointing just to see if eveything goes as expected?
s
@lorenzo affetti many thanks for your response. In my case I have observed that
Copy code
Triggered: 4924 In Progress: 0 Completed: 4808 Failed: 116 Restored: 113
I can disable checkpointing but could you please let me know how would it affect the acknowledgments and I am doing aggregration over a large window ? https://nightlies.apache.org/flink/flink-docs-master/docs/connectors/datastream/pubsub/#sourcefunction
l
I can disable checkpointing
Please, try that out and see if the job behaves as expected πŸ‘ From the docs you linked:
The PubSubSource will only acknowledge a message on successful checkpoints to guarantee at-least-once. This does mean if the time between successful checkpoints is larger than the acknowledgment deadline of your subscription messages will most likely be processed multiple times.
Basically, a successful checkpoint (yours are failing) would ACK the messages to be received and processed to Google Pub/Sub, so that Google would stop sending those to you multiple times. Clearly, if your checkpointing interval is too big compared with ACK deadline on Pub/Sub, messages would never get ACKed by Flink before their deadline and Google would replay them. Does the above clarify the behavior? So, either you decrease your checkpointing interval in Flink, or you increase your ACK deadline on Google. In any case, the above does not explain the anomaly you are seeing. Coming back to your original question:
but then duration gets reset to 0 and Record sent/received count and other metrics on flink dashboard shows as zero though records are being processed
That seems like a failure in the tasks, could you please check the TaskManager logs (it seems you only provided an exception at JM level)? A final question: do you see things that get processed somehow? Something printing to screen or ending up in one of your sinks?
s
@lorenzo affetti Thank you very much πŸ‘‹ for all the explanation, I will get back to you shortly with all answers.
Please, try that out and see if the job behaves as expected
:+1:
I think it requires checkpointing to be enabled all time.
Copy code
org.apache.flink.runtime.JobException: Recovery is suppressed by NoRestartBackoffTimeStrategy
    at org.apache.flink.runtime.rpc.pekko.PekkoRpcActor.lambda$handleRpcInvocation$1(PekkoRpcActor.java:309) ~[flink-rpc-akkabdc36157-cdac-4ea4-849b-27b38abca2dd.jar:1.18.0]
    at org.apache.flink.runtime.concurrent.ClassLoadingUtils.runWithContextClassLoader(ClassLoadingUtils.java:83) ~[flink-dist-1.18.0.jar:1.18.0]
    at org.apache.flink.runtime.rpc.pekko.PekkoRpcActor.handleRpcInvocation(PekkoRpcActor.java:307) ~[flink-rpc-akkabdc36157-cdac-4ea4-849b-27b38abca2dd.jar:1.18.0]
    at org.apache.flink.runtime.rpc.pekko.PekkoRpcActor.handleRpcMessage(PekkoRpcActor.java:222) ~[flink-rpc-akkabdc36157-cdac-4ea4-849b-27b38abca2dd.jar:1.18.0]
    at org.apache.flink.runtime.rpc.pekko.FencedPekkoRpcActor.handleRpcMessage(FencedPekkoRpcActor.java:85) ~[flink-rpc-akkabdc36157-cdac-4ea4-849b-27b38abca2dd.jar:1.18.0]
    at org.apache.flink.runtime.rpc.pekko.PekkoRpcActor.handleMessage(PekkoRpcActor.java:168) ~[flink-rpc-akkabdc36157-cdac-4ea4-849b-27b38abca2dd.jar:1.18.0]
    at org.apache.pekko.japi.pf.UnitCaseStatement.apply(CaseStatements.scala:33) [flink-rpc-akkabdc36157-cdac-4ea4-849b-27b38abca2dd.jar:1.18.0]
    at org.apache.pekko.japi.pf.UnitCaseStatement.apply(CaseStatements.scala:29) [flink-rpc-akkabdc36157-cdac-4ea4-849b-27b38abca2dd.jar:1.18.0]
    at scala.PartialFunction.applyOrElse(PartialFunction.scala:127) [flink-rpc-akkabdc36157-cdac-4ea4-849b-27b38abca2dd.jar:1.18.0]
    at scala.PartialFunction.applyOrElse$(PartialFunction.scala:126) [flink-rpc-akkabdc36157-cdac-4ea4-849b-27b38abca2dd.jar:1.18.0]
    at org.apache.pekko.japi.pf.UnitCaseStatement.applyOrElse(CaseStatements.scala:29) [flink-rpc-akkabdc36157-cdac-4ea4-849b-27b38abca2dd.jar:1.18.0]
    at scala.PartialFunction$OrElse.applyOrElse(PartialFunction.scala:175) [flink-rpc-akkabdc36157-cdac-4ea4-849b-27b38abca2dd.jar:1.18.0]
    at scala.PartialFunction$OrElse.applyOrElse(PartialFunction.scala:176) [flink-rpc-akkabdc36157-cdac-4ea4-849b-27b38abca2dd.jar:1.18.0]
    at scala.PartialFunction$OrElse.applyOrElse(PartialFunction.scala:176) [flink-rpc-akkabdc36157-cdac-4ea4-849b-27b38abca2dd.jar:1.18.0]
    at org.apache.pekko.actor.Actor.aroundReceive(Actor.scala:547) [flink-rpc-akkabdc36157-cdac-4ea4-849b-27b38abca2dd.jar:1.18.0]
    at org.apache.pekko.actor.Actor.aroundReceive$(Actor.scala:545) [flink-rpc-akkabdc36157-cdac-4ea4-849b-27b38abca2dd.jar:1.18.0]
    at org.apache.pekko.actor.AbstractActor.aroundReceive(AbstractActor.scala:229) [flink-rpc-akkabdc36157-cdac-4ea4-849b-27b38abca2dd.jar:1.18.0]
    at org.apache.pekko.actor.ActorCell.receiveMessage(ActorCell.scala:590) [flink-rpc-akkabdc36157-cdac-4ea4-849b-27b38abca2dd.jar:1.18.0]
    at org.apache.pekko.actor.ActorCell.invoke(ActorCell.scala:557) [flink-rpc-akkabdc36157-cdac-4ea4-849b-27b38abca2dd.jar:1.18.0]
    at org.apache.pekko.dispatch.Mailbox.processMailbox(Mailbox.scala:280) [flink-rpc-akkabdc36157-cdac-4ea4-849b-27b38abca2dd.jar:1.18.0]
    at org.apache.pekko.dispatch.Mailbox.run(Mailbox.scala:241) [flink-rpc-akkabdc36157-cdac-4ea4-849b-27b38abca2dd.jar:1.18.0]
    at org.apache.pekko.dispatch.Mailbox.exec(Mailbox.scala:253) [flink-rpc-akkabdc36157-cdac-4ea4-849b-27b38abca2dd.jar:1.18.0]
    at java.util.concurrent.ForkJoinTask.doExec(Unknown Source) [?:?]
    at java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(Unknown Source) [?:?]
    at java.util.concurrent.ForkJoinPool.scan(Unknown Source) [?:?]
    at java.util.concurrent.ForkJoinPool.runWorker(Unknown Source) [?:?]
    at java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source) [?:?]
Caused by: java.lang.IllegalArgumentException: The PubSubSource REQUIRES Checkpointing to be enabled and the checkpointing frequency must be MUCH lower than the PubSub timeout for it to retry a message.
    at org.apache.flink.streaming.connectors.gcp.pubsub.PubSubSource.open(PubSubSource.java:96) ~[?:?]
    at org.apache.flink.api.common.functions.util.FunctionUtils.openFunction(FunctionUtils.java:34) ~[flink-dist-1.18.0.jar:1.18.0]
    at org.apache.flink.streaming.api.operators.AbstractUdfStreamOperator.open(AbstractUdfStreamOperator.java:101) ~[flink-dist-1.18.0.jar:1.18.0]
    at org.apache.flink.streaming.runtime.tasks.RegularOperatorChain.initializeStateAndOpenOperators(RegularOperatorChain.java:107) ~[flink-dist-1.18.0.jar:1.18.0]
    at org.apache.flink.streaming.runtime.tasks.StreamTask.restoreGates(StreamTask.java:753) ~[flink-dist-1.18.0.jar:1.18.0]
    at org.apache.flink.streaming.runtime.tasks.StreamTaskActionExecutor$SynchronizedStreamTaskActionExecutor.call(StreamTaskActionExecutor.java:100) ~[flink-dist-1.18.0.jar:1.18.0]
    at org.apache.flink.streaming.runtime.tasks.StreamTask.restoreInternal(StreamTask.java:728) ~[flink-dist-1.18.0.jar:1.18.0]
    at org.apache.flink.streaming.runtime.tasks.StreamTask.restore(StreamTask.java:693) ~[flink-dist-1.18.0.jar:1.18.0]
    at org.apache.flink.runtime.taskmanager.Task.runWithSystemExitMonitoring(Task.java:953) ~[flink-dist-1.18.0.jar:1.18.0]
    at org.apache.flink.runtime.taskmanager.Task.restoreAndInvoke(Task.java:922) ~[flink-dist-1.18.0.jar:1.18.0]
    at org.apache.flink.runtime.taskmanager.Task.doRun(Task.java:746) ~[flink-dist-1.18.0.jar:1.18.0]
    at org.apache.flink.runtime.taskmanager.Task.run(Task.java:562) ~[flink-dist-1.18.0.jar:1.18.0]
    at java.lang.Thread.run(Unknown Source) ~[?:?]
    Suppressed: java.lang.NullPointerException
        at org.apache.flink.streaming.connectors.gcp.pubsub.PubSubSource.close(PubSubSource.java:137) ~[?:?]
        at org.apache.flink.api.common.functions.util.FunctionUtils.closeFunction(FunctionUtils.java:41) ~[flink-dist-1.18.0.jar:1.18.0]
        at org.apache.flink.streaming.api.operators.AbstractUdfStreamOperator.close(AbstractUdfStreamOperator.java:115) ~[flink-dist-1.18.0.jar:1.18.0]
        at org.apache.flink.streaming.api.operators.StreamSource.close(StreamSource.java:128) ~[flink-dist-1.18.0.jar:1.18.0]
        at org.apache.flink.streaming.runtime.tasks.StreamOperatorWrapper.close(StreamOperatorWrapper.java:163) ~[flink-dist-1.18.0.jar:1.18.0]
        at org.apache.flink.streaming.runtime.tasks.RegularOperatorChain.closeAllOperators(RegularOperatorChain.java:125) ~[flink-dist-1.18.0.jar:1.18.0]
        at org.apache.flink.streaming.runtime.tasks.StreamTask.closeAllOperators(StreamTask.java:1062) ~[flink-dist-1.18.0.jar:1.18.0]
        at org.apache.flink.util.IOUtils.closeAll(IOUtils.java:255) ~[flink-dist-1.18.0.jar:1.18.0]
        at org.apache.flink.core.fs.AutoCloseableRegistry.doClose(AutoCloseableRegistry.java:72) ~[flink-dist-1.18.0.jar:1.18.0]
        at org.apache.flink.util.AbstractAutoCloseableRegistry.close(AbstractAutoCloseableRegistry.java:127) ~[flink-dist-1.18.0.jar:1.18.0]
        at org.apache.flink.streaming.runtime.tasks.StreamTask.cleanUp(StreamTask.java:970) ~[flink-dist-1.18.0.jar:1.18.0]
        at org.apache.flink.runtime.taskmanager.Task.lambda$restoreAndInvoke$0(Task.java:935) ~[flink-dist-1.18.0.jar:1.18.0]
        at org.apache.flink.runtime.taskmanager.Task.runWithSystemExitMonitoring(Task.java:953) ~[flink-dist-1.18.0.jar:1.18.0]
        at org.apache.flink.runtime.taskmanager.Task.restoreAndInvoke(Task.java:935) ~[flink-dist-1.18.0.jar:1.18.0]
        at org.apache.flink.runtime.taskmanager.Task.doRun(Task.java:746) ~[flink-dist-1.18.0.jar:1.18.0]
        at org.apache.flink.runtime.taskmanager.Task.run(Task.java:562) ~[flink-dist-1.18.0.jar:1.18.0]
        at java.lang.Thread.run(Unknown Source) ~[?:?]
2024-03-06 22:13:17,486 INFO  org.apache.flink.runtime.checkpoint.CheckpointCoordinator    [] - Stopping checkpoint coordinator for job 3395ff6dd6fbaf8fce833a4d3d2fd7bb.
2024-03-06 22:13:17,487 WARN  org.apache.flink.runtime.taskmanager.TaskManagerLocation     [] - No hostname could be resolved for the IP address 10.20.3.152, using IP address as host name. Local input split assignment (such as for HDFS files) may be impacted.
2024-03-06 22:13:17,488 INFO  org.apache.flink.runtime.dispatcher.StandaloneDispatcher     [] - Job 3395ff6dd6fbaf8fce833a4d3d2fd7bb reached terminal state FAILED.
org.apache.flink.runtime.JobException: Recovery is suppressed by NoRestartBackoffTimeStrategy
    at org.apache.flink.runtime.executiongraph.failover.flip1.ExecutionFailureHandler.handleFailure(ExecutionFailureHandler.java:176)
    at org.apache.flink.runtime.executiongraph.failover.flip1.ExecutionFailureHandler.getFailureHandlingResult(ExecutionFailureHandler.java:107)
    at org.apache.flink.runtime.scheduler.DefaultScheduler.recordTaskFailure(DefaultScheduler.java:285)
    at org.apache.flink.runtime.scheduler.DefaultScheduler.handleTaskFailure(DefaultScheduler.java:276)
    at org.apache.flink.runtime.scheduler.DefaultScheduler.onTaskFailed(DefaultScheduler.java:269)
java.base/java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source)
Caused by: java.lang.IllegalArgumentException: The PubSubSource REQUIRES Checkpointing to be enabled and the checkpointing frequency must be MUCH lower than the PubSub timeout for it to retry a message.
    at org.apache.flink.streaming.connectors.gcp.pubsub.PubSubSource.open(PubSubSource.java:96)
Basically, a successful checkpoint (yours are failing) would ACK the messages to be received and processed to Google Pub/Sub, so that Google would stop sending those to you multiple times.
Clearly, if your checkpointing interval is too big compared with ACK deadline on Pub/Sub, messages would never get ACKed by Flink before their deadline and Google would replay them.
Does the above clarify the behavior?
So, either you decrease your checkpointing interval in Flink, or you increase your ACK deadline on Google.
So yes my checkpointing interval is 10 seconds and ack deadline is 600 seconds so checkpointing interval is much lower than ack deadline.
That seems like a failure in the tasks, could you please check the TaskManager logs (it seems you only provided an exception at JM level)?
Copy code
2024-03-06 22:24:48
org.apache.flink.util.FlinkRuntimeException: Exceeded checkpoint tolerable failure threshold. The latest checkpoint failed due to Asynchronous task checkpoint failed., view the Checkpoint History tab or the Job Manager log to find out why continuous checkpoints failed.
	at org.apache.flink.runtime.checkpoint.CheckpointFailureManager.checkFailureAgainstCounter(CheckpointFailureManager.java:212)
	at org.apache.flink.runtime.checkpoint.CheckpointFailureManager.handleTaskLevelCheckpointException(CheckpointFailureManager.java:191)
	at org.apache.flink.runtime.checkpoint.CheckpointFailureManager.handleCheckpointException(CheckpointFailureManager.java:124)
	at org.apache.flink.runtime.checkpoint.CheckpointCoordinator.abortPendingCheckpoint(CheckpointCoordinator.java:2151)
	at org.apache.flink.runtime.checkpoint.CheckpointCoordinator.receiveDeclineMessage(CheckpointCoordinator.java:1100)
	at org.apache.flink.runtime.scheduler.ExecutionGraphHandler.lambda$declineCheckpoint$2(ExecutionGraphHandler.java:103)
	at org.apache.flink.runtime.scheduler.ExecutionGraphHandler.lambda$processCheckpointCoordinatorMessage$3(ExecutionGraphHandler.java:119)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)
Logs of JobManager
Copy code
2024-03-06 22:24:48,685 INFO  org.apache.flink.runtime.checkpoint.CheckpointCoordinator    [] - Decline checkpoint 6 by task 85eae1f113695872d31e3e7a7a767d78_e9da2c136943b6e07e65f1def2aa74ea_5_0 of job 8cc95e309ec863ef4fa0182c2655a400 at 10.20.18.195:6122-72dbc5 @ 10.20.18.195 (dataPort=34313).
org.apache.flink.util.SerializedThrowable: org.apache.flink.runtime.checkpoint.CheckpointException: Asynchronous task checkpoint failed.
	at org.apache.flink.streaming.runtime.tasks.AsyncCheckpointRunnable.handleExecutionException(AsyncCheckpointRunnable.java:320) ~[flink-dist-1.18.0.jar:1.18.0]
	at org.apache.flink.streaming.runtime.tasks.AsyncCheckpointRunnable.run(AsyncCheckpointRunnable.java:155) ~[flink-dist-1.18.0.jar:1.18.0]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:?]
	at java.lang.Thread.run(Unknown Source) [?:?]
Caused by: org.apache.flink.util.SerializedThrowable: java.lang.Exception: Could not materialize checkpoint 6 for operator Source: InstitutionSource (6/8)#0.
	at org.apache.flink.streaming.runtime.tasks.AsyncCheckpointRunnable.handleExecutionException(AsyncCheckpointRunnable.java:298) ~[flink-dist-1.18.0.jar:1.18.0]
	... 4 more
Caused by: org.apache.flink.util.SerializedThrowable: java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: Java heap space
	at java.util.concurrent.FutureTask.report(Unknown Source) ~[?:?]
	at java.util.concurrent.FutureTask.get(Unknown Source) ~[?:?]
	at org.apache.flink.util.concurrent.FutureUtils.runIfNotDoneAndGet(FutureUtils.java:511) ~[flink-dist-1.18.0.jar:1.18.0]
	at org.apache.flink.streaming.api.operators.OperatorSnapshotFinalizer.<init>(OperatorSnapshotFinalizer.java:60) ~[flink-dist-1.18.0.jar:1.18.0]
	at org.apache.flink.streaming.runtime.tasks.AsyncCheckpointRunnable.finalizeNonFinishedSnapshots(AsyncCheckpointRunnable.java:191) ~[flink-dist-1.18.0.jar:1.18.0]
	at org.apache.flink.streaming.runtime.tasks.AsyncCheckpointRunnable.run(AsyncCheckpointRunnable.java:124) ~[flink-dist-1.18.0.jar:1.18.0]
	... 3 more
Caused by: org.apache.flink.util.SerializedThrowable: java.lang.OutOfMemoryError: Java heap space
2024-03-06 22:24:48,686 WARN  org.apache.flink.runtime.checkpoint.CheckpointFailureManager [] - Failed to trigger or complete checkpoint 6 for job 8cc95e309ec863ef4fa0182c2655a400. (0 consecutive failed attempts so far)
org.apache.flink.runtime.checkpoint.CheckpointException: Asynchronous task checkpoint failed.
	at org.apache.flink.runtime.messages.checkpoint.SerializedCheckpointException.unwrap(SerializedCheckpointException.java:51) ~[flink-dist-1.18.0.jar:1.18.0]
	at org.apache.flink.runtime.checkpoint.CheckpointCoordinator.receiveDeclineMessage(CheckpointCoordinator.java:1074) ~[flink-dist-1.18.0.jar:1.18.0]
	at org.apache.flink.runtime.scheduler.ExecutionGraphHandler.lambda$declineCheckpoint$2(ExecutionGraphHandler.java:103) ~[flink-dist-1.18.0.jar:1.18.0]
	at org.apache.flink.runtime.scheduler.ExecutionGraphHandler.lambda$processCheckpointCoordinatorMessage$3(ExecutionGraphHandler.java:119) ~[flink-dist-1.18.0.jar:1.18.0]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:?]
	at java.lang.Thread.run(Unknown Source) [?:?]
Caused by: org.apache.flink.util.SerializedThrowable: org.apache.flink.runtime.checkpoint.CheckpointException: Asynchronous task checkpoint failed.
	at org.apache.flink.streaming.runtime.tasks.AsyncCheckpointRunnable.handleExecutionException(AsyncCheckpointRunnable.java:320) ~[flink-dist-1.18.0.jar:1.18.0]
	at org.apache.flink.streaming.runtime.tasks.AsyncCheckpointRunnable.run(AsyncCheckpointRunnable.java:155) ~[flink-dist-1.18.0.jar:1.18.0]
	... 3 more
Caused by: org.apache.flink.util.SerializedThrowable: java.lang.Exception: Could not materialize checkpoint 6 for operator Source: InstitutionSource (6/8)#0.
	at org.apache.flink.streaming.runtime.tasks.AsyncCheckpointRunnable.handleExecutionException(AsyncCheckpointRunnable.java:298) ~[flink-dist-1.18.0.jar:1.18.0]
	at org.apache.flink.streaming.runtime.tasks.AsyncCheckpointRunnable.run(AsyncCheckpointRunnable.java:155) ~[flink-dist-1.18.0.jar:1.18.0]
	... 3 more
Caused by: org.apache.flink.util.SerializedThrowable: java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: Java heap space
	at java.util.concurrent.FutureTask.report(Unknown Source) ~[?:?]
	at java.util.concurrent.FutureTask.get(Unknown Source) ~[?:?]
	at org.apache.flink.util.concurrent.FutureUtils.runIfNotDoneAndGet(FutureUtils.java:511) ~[flink-dist-1.18.0.jar:1.18.0]
	at org.apache.flink.streaming.api.operators.OperatorSnapshotFinalizer.<init>(OperatorSnapshotFinalizer.java:60) ~[flink-dist-1.18.0.jar:1.18.0]
	at org.apache.flink.streaming.runtime.tasks.AsyncCheckpointRunnable.finalizeNonFinishedSnapshots(AsyncCheckpointRunnable.java:191) ~[flink-dist-1.18.0.jar:1.18.0]
	at org.apache.flink.streaming.runtime.tasks.AsyncCheckpointRunnable.run(AsyncCheckpointRunnable.java:124) ~[flink-dist-1.18.0.jar:1.18.0]
	... 3 more
Caused by: org.apache.flink.util.SerializedThrowable: java.lang.OutOfMemoryError: Java heap space
2024-03-06 22:24:48,687 WARN  org.apache.flink.runtime.checkpoint.CheckpointCoordinator    [] - Received late message for now expired checkpoint attempt 6 from task 85eae1f113695872d31e3e7a7a767d78_e9da2c136943b6e07e65f1def2aa74ea_4_0 of job 8cc95e309ec863ef4fa0182c2655a400 at 10.20.18.195:6122-72dbc5 @ 10.20.18.195 (dataPort=34313).
2024-03-06 22:24:48,687 INFO  org.apache.flink.runtime.jobmaster.JobMaster                 [] - Trying to recover from a global failure.
org.apache.flink.util.FlinkRuntimeException: Exceeded checkpoint tolerable failure threshold. The latest checkpoint failed due to Asynchronous task checkpoint failed., view the Checkpoint History tab or the Job Manager log to find out why continuous checkpoints failed.
	at org.apache.flink.runtime.checkpoint.CheckpointFailureManager.checkFailureAgainstCounter(CheckpointFailureManager.java:212) ~[flink-dist-1.18.0.jar:1.18.0]
	at org.apache.flink.runtime.checkpoint.CheckpointFailureManager.handleTaskLevelCheckpointException(CheckpointFailureManager.java:191) ~[flink-dist-1.18.0.jar:1.18.0]
	at org.apache.flink.runtime.checkpoint.CheckpointFailureManager.handleCheckpointException(CheckpointFailureManager.java:124) ~[flink-dist-1.18.0.jar:1.18.0]
	at org.apache.flink.runtime.checkpoint.CheckpointCoordinator.abortPendingCheckpoint(CheckpointCoordinator.java:2151) ~[flink-dist-1.18.0.jar:1.18.0]
	at org.apache.flink.runtime.checkpoint.CheckpointCoordinator.receiveDeclineMessage(CheckpointCoordinator.java:1100) ~[flink-dist-1.18.0.jar:1.18.0]
	at org.apache.flink.runtime.scheduler.ExecutionGraphHandler.lambda$declineCheckpoint$2(ExecutionGraphHandler.java:103) ~[flink-dist-1.18.0.jar:1.18.0]
	at org.apache.flink.runtime.scheduler.ExecutionGraphHandler.lambda$processCheckpointCoordinatorMessage$3(ExecutionGraphHandler.java:119) ~[flink-dist-1.18.0.jar:1.18.0]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) ~[?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) ~[?:?]
	at java.lang.Thread.run(Unknown Source) ~[?:?]
2024-03-06 22:24:48,688 INFO  org.apache.flink.runtime.jobmaster.JobMaster                 [] - 16 tasks will be restarted to recover from a global failure.
A final question:
do you see things that get processed somehow? Something printing to screen or ending up in one of your sinks?
yes my sink is cloud storage and I am seeing data there every hour as my window is 1 hour.
I observed one thing i.e. even if I increased
managed memory
of taskmanager with 7 slots from 512 MB to 1.12 GB, it fills pretty quickly full. I am using rocksdb as state backend. I am not sure how do I fine tune this ?
l
First things first, let's find a way to have the job work, and then we can find a good compromise. I am not sure why the TM goes out of memory while finalizing the snapshot πŸ€” Especially if you are using RocsDB backend, you should not encounter memory issues as the state can spill to disk. Let's try to reduce time window size (just to see if that solves the issue temporarily).
I am not sure how do I fine tune this ?
Take into consideration that the snapshot would account for all the messages to ACK (see https://github.com/apache/flink-connector-gcp-pubsub/blob/main/flink-connector-gcp[…]aming/connectors/gcp/pubsub/common/AcknowledgeOnCheckpoint.java), if you ingest many messages, you will end up storing big state snapshots (again, with RocksDB this is not an issue). Can you provide more information about your job?: β€’ You said your checkpoint interval is 10s. How many messages you receive in 10s (roughly)? β€’ What is the window state? Which kind of window are you using? BTW, trying to help you, but I am not an expert of that part of Flink's codebase πŸ‘
s
Let's try to reduce time window size (just to see if that solves the issue temporarily).
My current window is 1 hour and as per my use case I am gonna go for 1 day so even if I make it work for smaller window, it won't help at all IMHO.
Can you provide more information about your job?:
β€’ You said your checkpoint interval is 10s. How many messages you receive in 10s (roughly)?
I'd configured message pull configuration 300 so roughly 300-400 messages per second. My message consumption pattern like this.
β€’ What is the window state? Which kind of window are you using?
I am using TumblingProcessingTime Window and In the state I am using aggregrate function to aggregrate data over a key. TUMBLING_PROCESSING_WINDOW_FOR_AGGREGRATED_MECHANICAL_DATA => 1 hour but I want to make it 1 day eventually.
Copy code
DataStream<Tuple2<MechanicalGroupIdentifier, String>> aggregratedResult1 = txnStream
            .keyBy(i -> new MechanicalGroupIdentifier(i.getMechanicalId().toString(), i.getEndpoint().toString(), i.getVersion().toString()))
            .window(TumblingProcessingTimeWindows.of(Time.minutes(TUMBLING_PROCESSING_WINDOW_FOR_AGGREGRATED_MECHANICAL_DATA)))
            .aggregate(new AggregateFunction<MechanicalRequestMetric, Tuple2<MechanicalGroupIdentifier, MechanicalRequestOutput>, Tuple2<MechanicalGroupIdentifier, String>>() {
                @Override
                public Tuple2<MechanicalGroupIdentifier, MechanicalRequestOutput> createAccumulator() {
                    return new Tuple2<>();
                }

                @Override
                public Tuple2<MechanicalGroupIdentifier, MechanicalRequestOutput> add(
                    MechanicalRequestMetric mechanicalRequestMetric,
                    Tuple2<MechanicalGroupIdentifier, MechanicalRequestOutput> mechanicalGroupIdentifierMechanicalRequestOutputMap) {
                    MechanicalGroupIdentifier mechanicalGroupIdentifier = new MechanicalGroupIdentifier(
                        mechanicalRequestMetric.getMechanicalId().toString(),
                        mechanicalRequestMetric.getEndpoint().toString(),
                        mechanicalRequestMetric.getVersion().toString());
                    LOG.info("mechanical group identifier is {}", mechanicalGroupIdentifier.toString());
                    MechanicalRequestOutput mechanicalRequestOutput = mechanicalGroupIdentifierMechanicalRequestOutputMap.f1 == null ? new MechanicalRequestOutput() : mechanicalGroupIdentifierMechanicalRequestOutputMap.f1;
                    if(mechanicalRequestMetric.getStatus() == 200 || mechanicalRequestMetric.getStatus() == 201 || mechanicalRequestMetric.getStatus() == 204)
                        mechanicalRequestOutput.setSuccessfulApiCalls(mechanicalRequestOutput != null ? mechanicalRequestOutput.getSuccessfulApiCalls()+1 : 1);
                    else if (mechanicalRequestMetric.getStatus() >= 400 && mechanicalRequestMetric.getStatus() < 500) {
                        mechanicalRequestOutput.setFailedApiBusinessCalls(mechanicalRequestOutput != null ? mechanicalRequestOutput.getFailedApiBusinessCalls()+1 : 1);
                    } else if(mechanicalRequestMetric.getStatus() >= 500 && mechanicalRequestMetric.getStatus() < 600) {
                        mechanicalRequestOutput.setFailedApiTechnicalCalls(mechanicalRequestOutput != null ? mechanicalRequestOutput.getFailedApiTechnicalCalls()+1 : 1);
                    } else {
                        mechanicalRequestOutput.setUnknownStatusCalls(mechanicalRequestOutput != null ? mechanicalRequestOutput.getUnknownStatusCalls()+1 : 1);
                    }
                    int endpointId = -1;
                    if(APPROXIMATE_ENDPOINT_MAPPING) {
                        endpointId = mechanicalIdExtractor.extractEndpointIdApproximate(mechanicalGroupIdentifier.getEndpoint());
                    } else {
                        endpointId = mechanicalIdExtractor.extractEndpointId(mechanicalGroupIdentifier.getEndpoint());
                    }
                    String mechanicalIdFinal = mechanicalGroupIdentifier.getMechanicalId();
                    long id = MechanicalIdExtractor.getMechanicalId(mechanicalGroupIdentifier.getMechanicalId());
                    if(id != -1)
                        mechanicalIdFinal = String.valueOf(id);
                    mechanicalRequestOutput.setMechanicalId(mechanicalIdFinal);
                    mechanicalRequestOutput.setTppId(6720);
                    mechanicalRequestOutput.setReportingDate(LocalDate.now().toString());
                    mechanicalRequestOutput.setEndpointVersion(mechanicalGroupIdentifier.getVersion());
                    mechanicalRequestOutput.setEndpointId(endpointId);
                    LOG.info("mechanical request output is {}", mechanicalRequestOutput.toString());
                    return new Tuple2<>(mechanicalGroupIdentifier, mechanicalRequestOutput);
                }

                @Override
                public Tuple2<MechanicalGroupIdentifier, String> getResult(
                    Tuple2<MechanicalGroupIdentifier, MechanicalRequestOutput> mechanicalGroupIdentifierMechanicalRequestOutputMap) {
                    return Tuple2.of(mechanicalGroupIdentifierMechanicalRequestOutputMap.f0, mechanicalGroupIdentifierMechanicalRequestOutputMap.f1.toString());
                }

                @Override
                public Tuple2<MechanicalGroupIdentifier, MechanicalRequestOutput> merge(
                    Tuple2<MechanicalGroupIdentifier, MechanicalRequestOutput> mechanicalGroupIdentifierMechanicalRequestOutputMap,
                    Tuple2<MechanicalGroupIdentifier, MechanicalRequestOutput> acc1) {
                    if(mechanicalGroupIdentifierMechanicalRequestOutputMap.f0.equals(acc1.f0)) {
                        MechanicalRequestOutput mechanicalRequestOutput = acc1.f1;
                        mechanicalRequestOutput.setSuccessfulApiCalls(mechanicalRequestOutput.getSuccessfulApiCalls()+acc1.f1.getSuccessfulApiCalls());
                        mechanicalRequestOutput.setFailedApiBusinessCalls(mechanicalRequestOutput.getFailedApiBusinessCalls()+acc1.f1.getFailedApiBusinessCalls());
                        mechanicalRequestOutput.setFailedApiTechnicalCalls(mechanicalRequestOutput.getFailedApiTechnicalCalls()+acc1.f1.getFailedApiTechnicalCalls());
                        mechanicalRequestOutput.setUnknownStatusCalls(mechanicalRequestOutput.getUnknownStatusCalls()+acc1.f1.getUnknownStatusCalls());
                        return Tuple2.of(acc1.f0, mechanicalRequestOutput);
                    }
                    return null;
                }
            })
            .setParallelism(AVAILABLE_PROCESSORS);
I am not sure why the TM goes out of memory while finalizing the snapshot πŸ€”
Especially if you are using RocsDB backend, you should not encounter memory issues as the state can spill to disk.
I was thinking on the same lines and wondering why it is happening. I found a relevant stackoverflow link. https://stackoverflow.com/questions/70986020/flink-job-requiring-a-lot-of-memory-despite-using-rocksdb-state-backend
l
Sorry, I was away for a week πŸ‘ Some back of the envelope calculations: You said 300 msgs/s, this means a window of 1 hour can store 60 * 60 * 300 = ~1M messages. Say a message 1KB, then you easily get to 1GB per window πŸ‘ I was re-reading now our conversation, and I think I kind of missed it before: from what I can understand from your exceptions, the checkpointing fails at JM level, and I think we are focusing now on the TM. How is your memory setting for the JM? Can you increase that and retry? Probably we are just concerned about the wrong problems πŸ‘