Hi Everyone, I tried running my stream join job on...
# troubleshooting
r
Hi Everyone, I tried running my stream join job on Kinesis and I think I may be having some memory issues. Locally, my job runs fine with
memory.size
set to 4096. However, I can't set config properties on kinesis because kinesis does not allow
flink-conf.yaml
. This is the error stack trace below. Does any have suggestions on how to resolve this?
Copy code
2023-03-09 12:40:24
java.lang.Exception: Exception while creating StreamOperatorStateContext.
	at org.apache.flink.streaming.api.operators.StreamTaskStateInitializerImpl.streamOperatorStateContext(StreamTaskStateInitializerImpl.java:255)
	at org.apache.flink.streaming.api.operators.AbstractStreamOperator.initializeState(AbstractStreamOperator.java:268)
	at org.apache.flink.streaming.runtime.tasks.RegularOperatorChain.initializeStateAndOpenOperators(RegularOperatorChain.java:106)
	at org.apache.flink.streaming.runtime.tasks.StreamTask.restoreGates(StreamTask.java:700)
	at org.apache.flink.streaming.runtime.tasks.StreamTaskActionExecutor$1.call(StreamTaskActionExecutor.java:55)
	at org.apache.flink.streaming.runtime.tasks.StreamTask.restoreInternal(StreamTask.java:676)
	at org.apache.flink.streaming.runtime.tasks.StreamTask.restore(StreamTask.java:643)
	at org.apache.flink.runtime.taskmanager.Task.runWithSystemExitMonitoring(Task.java:953)
	at org.apache.flink.runtime.taskmanager.Task.restoreAndInvoke(Task.java:922)
	at org.apache.flink.runtime.taskmanager.Task.doRun(Task.java:746)
	at org.apache.flink.runtime.taskmanager.Task.run(Task.java:568)
	at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: org.apache.flink.util.FlinkException: Could not restore keyed state backend for WindowOperator_7e145440e6a4bf9d4540b5d7293494cc_(1/1) from any of the 1 provided restore options.
	at org.apache.flink.streaming.api.operators.BackendRestorerProcedure.createAndRestore(BackendRestorerProcedure.java:160)
	at org.apache.flink.streaming.api.operators.StreamTaskStateInitializerImpl.keyedStatedBackend(StreamTaskStateInitializerImpl.java:346)
	at org.apache.flink.streaming.api.operators.StreamTaskStateInitializerImpl.streamOperatorStateContext(StreamTaskStateInitializerImpl.java:164)
	... 11 more
Caused by: java.io.IOException: Failed to acquire shared cache resource for RocksDB
	at org.apache.flink.contrib.streaming.state.RocksDBOperationUtils.allocateSharedCachesIfConfigured(RocksDBOperationUtils.java:296)
	at org.apache.flink.contrib.streaming.state.EmbeddedRocksDBStateBackend.createKeyedStateBackend(EmbeddedRocksDBStateBackend.java:444)
	at org.apache.flink.contrib.streaming.state.EmbeddedRocksDBStateBackend.createKeyedStateBackend(EmbeddedRocksDBStateBackend.java:97)
	at org.apache.flink.streaming.api.operators.StreamTaskStateInitializerImpl.lambda$keyedStatedBackend$1(StreamTaskStateInitializerImpl.java:329)
	at org.apache.flink.streaming.api.operators.BackendRestorerProcedure.attemptCreateAndRestore(BackendRestorerProcedure.java:168)
	at org.apache.flink.streaming.api.operators.BackendRestorerProcedure.createAndRestore(BackendRestorerProcedure.java:135)
	... 13 more
Caused by: java.lang.IllegalArgumentException: The fraction of memory to allocate should not be 0. Please make sure that all types of managed memory consumers contained in the job are configured with a non-negative weight via `taskmanager.memory.managed.consumer-weights`.
	at org.apache.flink.util.Preconditions.checkArgument(Preconditions.java:160)
	at org.apache.flink.runtime.memory.MemoryManager.validateFraction(MemoryManager.java:672)
	at org.apache.flink.runtime.memory.MemoryManager.computeMemorySize(MemoryManager.java:653)
	at org.apache.flink.runtime.memory.MemoryManager.getSharedMemoryResourceForManagedMemory(MemoryManager.java:521)
	at org.apache.flink.contrib.streaming.state.RocksDBOperationUtils.allocateSharedCachesIfConfigured(RocksDBOperationUtils.java:292)
	... 18 more
j
when you say
kinesis
are you referring to kinesis data analytics?
Copy code
The fraction of memory to allocate should not be 0.
Was this set in your flink-conf.yaml?
r
yes kinesis data analytics
From what I know you can't set flink-conf.yaml on KDA
Is there a way to do so?
j
hi @Reme Ajayi could you create a support ticket on this? KDA Engineering could have a look as to why you’d be seeing this
r
I've done that
👏 1
j
but out of curiosity what is the job doing that warrants custom memory settings?
could you link to the ticket here?
or in a DM
r
It's a complex join.
j
got it--what is your expected throughput and how many KPUs?
r
I'm actually relatively new to Flink so I don't know if I should be using more memory, however I am able to run my job locally without any issues when I update the memory size.
I am trying to calculate the expected throughput with Kinesis actually so I don't know that value
I have set my Parallelism to 1
My data is coming from 4 kafka topics, each with only one partition
I am processing a few GB of data from these topics
j
we generally recommend that for each 1MB of data ingested (per second) you should allocate 1 KPU. Since you have a few GB in your topics that will likely all get pulled in to KDA all at once this is likely underprovisioned
r
Oh Wow. Thank you for this explanation
Let me increase the parallelism & parallelism per kpu and see if that fixes the issue
It failed with the default 12 so I'll increase it and see if it improves the situation
j
definitely don’t want to blow out your bill--perhaps we can understand your architecture better
is this a batch application?
r
No it's a streaming application
j
ideally flink wouldn’t pull in several GBs all at once into a streaming app
it works best with smaller more predictable ingest patterns
so is this an expected pattern to pull in GBs worth at a time?
r
This is what the application architecture looks like in my local environment
It's run for about 6 hours so all the GB received was spread out over that time
j
Ah okay so after that 6 hours it threw the error right
r
No, it ran for 6 hours locally. But it threw the error as soon as it started on KDA
j
Ah okay is this screenshot from local or KDA
r
The screenshot is from local, I was trying to show you the architecture.
The Sources are all from Kafka
j
Got it got it. I'm not sure about the error but it could be underprovsioned. Take a look at the containerCPUUtilization and containedMemoryUtilization of your application in cloud watch this may give us more info
👍 1
r
I can't get a CPUUtilization values cause it's not running at all
It goes straight to a restart loop with that error
j
Hmm okay. Are you restoring from save points when you start the app or just starting fresh
r
starting fresh
j
Ok I'll have service team review ticket
r
thank you
Hi @Jeremy Ber thanks for your input yesterday. You're totally right about the CPU utilization. I monitored things more closely today and saw that the CPU utilization actually hit 100%. More Job Details:
j
ah okay--do you have autoscaling turned on?
r
Yes I do
j
so this app may be autoscaling given that. Can you show containerCPUUtilization as well?
r
I'm currently using a Parallelism of 32 and ParallelismPerKPU of 8.
j
ahh--let’s try setting the PPKPU down to 1, we generally only recommend this going higher with I/O bound applications
r
Locally, the sources are receiving about 3MB per second if this provides any more insight
Okay PPKPU to 1 and should parallelism stay at 32
j
you can leave parallelism at 32 for now but i think that’s likely too much for 3MB/s--is that across all 4 topics?
🙏 1
r
Oh no, this is a smaller job with just two topics. It's giving the same error though, the other job probably has 4x as much
🆗 1
The CPU Utilization is down but the job fails with the same error. I looked at the default task manager memory and it many times more than my local setup.
j
sounds good--will follow up here once the ticket is resolved 🙂
gratitude thank you 1
r
Hey @Jeremy Ber, AWS reached out with a solution, the problem was that I set the stateBackend which Kinesis does not allow.
j
Excellent!
For clarification, Reme--you can change your stateBackend on KDA with a service ticket but not through code. Let me know if this is something you’re looking to do
r
The default is fine thank you