Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 85B94200C04 for ; Tue, 24 Jan 2017 15:07:34 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 843AD160B3D; Tue, 24 Jan 2017 14:07:34 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 5DA64160B31 for ; Tue, 24 Jan 2017 15:07:33 +0100 (CET) Received: (qmail 58169 invoked by uid 500); 24 Jan 2017 14:07:32 -0000 Mailing-List: contact user-help@flink.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@flink.apache.org Delivered-To: mailing list user@flink.apache.org Received: (qmail 58138 invoked by uid 99); 24 Jan 2017 14:07:32 -0000 Received: from mail-relay.apache.org (HELO mail-relay.apache.org) (140.211.11.15) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 24 Jan 2017 14:07:32 +0000 Received: from mail-it0-f46.google.com (mail-it0-f46.google.com [209.85.214.46]) by mail-relay.apache.org (ASF Mail Server at mail-relay.apache.org) with ESMTPSA id F26DD1A018B for ; Tue, 24 Jan 2017 14:07:31 +0000 (UTC) Received: by mail-it0-f46.google.com with SMTP id r185so90419629ita.0 for ; Tue, 24 Jan 2017 06:07:31 -0800 (PST) X-Gm-Message-State: AIkVDXLOuegEJPrtK+DYeb5ddnuNhqBkMacfP7l0u3DlIB5PowSuB5HKDUfTKBR7o3N3n9oRp0Gl8Eki2YKbbA== X-Received: by 10.36.10.3 with SMTP id 3mr19077442itw.108.1485266851135; Tue, 24 Jan 2017 06:07:31 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.19.101 with HTTP; Tue, 24 Jan 2017 06:07:30 -0800 (PST) In-Reply-To: References: <9AE06EB3-2CCA-4C25-BEEB-CDFDBCDEBC20@expedia.com> From: Stephan Ewen Date: Tue, 24 Jan 2017 15:07:30 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Rapidly failing job eventually causes "Not enough free slots" To: user@flink.apache.org Content-Type: multipart/alternative; boundary=001a1143e4ce0f28c60546d7a391 archived-at: Tue, 24 Jan 2017 14:07:34 -0000 --001a1143e4ce0f28c60546d7a391 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi! I think there were some issues in the HA recovery of 1.1.3 that were fixed in 1.1.4 and 1.2.0. What version are you running on? Stephan On Sat, Jan 21, 2017 at 4:58 PM, Ufuk Celebi wrote: > Hey Shannon, > > the final truth for recovery is in ZooKeeper. Can you check whether > there also references available in ZooKeeper? Do you have the job > manager logs available from after the failure? On recovery, Flink > checks ZooKeeper for entries. These point to files in the storageDir. > It could have happened that these got out of sync, e.g. entries > deleted from ZK but not from the storageDir. > > Maybe the loss of the task managers can also be explained by a > connection loss to ZK or something. When a JM looses leadership, the > TMs cancel all tasks and disconnect from the JM. Here again, we would > need to look into the logs. > > Sorry for the bad experience lately :-( > > =E2=80=93 Ufuk > > > On Sat, Jan 21, 2017 at 4:31 AM, Shannon Carey wrote= : > > In fact, I can see all my job jar blobs and some checkpoint & job graph > > files in my configured "recovery.zookeeper.storageDir"=E2=80=A6 however= for some > > reason it didn't get restored when my new Flink cluster started up. > > > > > > From: Shannon Carey > > Date: Friday, January 20, 2017 at 9:14 PM > > To: "user@flink.apache.org" > > > > Subject: Re: Rapidly failing job eventually causes "Not enough free > slots" > > > > I recently added some better visibility into the metrics we're gatherin= g > > from Flink. My Flink cluster died again due to the "Not enough free slo= ts > > available to run the job" problem, and this time I can see that the > number > > of registered task managers went down from 11 to 7, then waffled and on= ly > > ever got back up to 10 (one short of the requested amount) before > dropping > > to 0 just before the cluster died. This would seem to explain why there > > weren't sufficient slots (given that we were probably using them all or > > nearly all)=E2=80=A6 The metric of "running jobs" went down from 5 to 3= during > this > > time period as well. So the problem seems to be loss of taskmanagers du= e > to > > errors (not yet sure what exactly as I have to delve into logs). > > > > The other thing I have to figure out is restoring the jobs=E2=80=A6 I t= hought > that > > HA would start the jobs back up again if Flink died & I re-launched it, > but > > that doesn't appear to be the case. > > > > > > From: Stephan Ewen > > Date: Thursday, January 5, 2017 at 7:52 AM > > To: > > Subject: Re: Rapidly failing job eventually causes "Not enough free > slots" > > > > Another thought on the container failure: > > > > in 1.1, the user code is loaded dynamically whenever a Task is started. > That > > means that on every task restart the code is reloaded. For that to work > > proper, class unloading needs to happen, or the permgen will eventually > > overflow. > > > > It can happen that class unloading is prevented if the user functions d= o > > leave references around as "GC roots", which may be threads, or > references > > in registries, etc. > > > > In Flink 1.2, YARN will put the user code into the application > classpath, so > > code needs not be reloaded on every restart. That should solve that > issue. > > To "simulate" that behavior in Flink 1.1, put your application code jar= s > > into the "lib" folder > > > > Best, > > Stephan > > > > > > On Thu, Jan 5, 2017 at 1:15 PM, Yury Ruchin > wrote: > >> > >> Hi, > >> > >> I've faced a similar issue recently. Hope sharing my findings will hel= p. > >> The problem can be split into 2 parts: > >> > >> Source of container failures > >> The logs you provided indicate that YARN kills its containers for > >> exceeding memory limits. Important point here is that memory limit =3D= JVM > >> heap memory + off-heap memory. So if off-heap memory usage is high, > YARN may > >> kill containers despite JVM heap consumption is fine. To solve this > issue, > >> Flink reserves a share of container memory for off-heap memory. How mu= ch > >> will be reserved is controlled by yarn.heap-cutoff-ratio and > >> yarn.heap-cutoff-min configuration. By default 25% of the requested > >> container memory will be reserved for off-heap. This is seems to be a > good > >> start, but one should experiment and tune to meet their job specifics. > >> > >> It's also worthwhile to figure out who consumes off-heap memory. Is it > >> Flink managed memory moved off heap (taskmanager.memory.off-heap =3D > true)? Is > >> it some external library allocating something off heap? Is it your own > code? > >> > >> How Flink handles task manager failures > >> Whenever a task manager fails, the Flink jobmanager decides whether it > >> should: > >> - reallocate failed task manager container > >> - fail application entirely > >> These decisions can be guided by certain configuration > >> (https://ci.apache.org/projects/flink/flink-docs- > release-1.1/setup/yarn_setup.html#recovery-behavior-of-flink-on-yarn). > >> With default settings, job manager does reallocate task manager > containers > >> up to the point when N failures have been observed, where N is the > number of > >> requested task managers. After that the application is stopped. > >> > >> According to the logs, you have a finite number in > >> yarn.maximum-failed-containers (11, as I can see from the logs - this > may be > >> set by Flink if not provided explicitly). On 12th container restart, > >> jobmanager gives up and the application stops. I'm not sure why it kee= ps > >> reporting not enough slots after that point. In my experience this may > >> happen when job eats up all the available slots, so that after contain= er > >> failure its tasks cannot be restarted in other (live) containers. But = I > >> believe once the decision to stop the application is made, there shoul= d > not > >> be any further attempts to restart the job, hence no logs like those. > >> Hopefully, someone else will explain this to us :) > >> > >> In my case I made jobmanager restart containers infinitely by setting > >> yarn.maximum-failed-containers =3D -1, so that taskmanager failure nev= er > >> results in application death. Note this is unlikely a good choice for = a > >> batch job. > >> > >> Regards, > >> Yury > >> > >> 2017-01-05 3:21 GMT+03:00 Shannon Carey : > >>> > >>> In Flink 1.1.3 on emr-5.2.0, I've experienced a particular problem > twice > >>> and I'm wondering if anyone has some insight about it. > >>> > >>> In both cases, we deployed a job that fails very frequently (within > >>> 15s-1m of launch). Eventually, the Flink cluster dies. > >>> > >>> The sequence of events looks something like this: > >>> > >>> bad job is launched > >>> bad job fails & is restarted many times (I didn't have the > "failure-rate" > >>> restart strategy configuration right) > >>> Task manager logs: org.apache.flink.yarn.YarnTaskManagerRunner > (SIGTERM > >>> handler): RECEIVED SIGNAL 15: SIGTERM. Shutting down as requested. > >>> At this point, the YARN resource manager also logs the container > failure > >>> More logs: Container > >>> ResourceID{resourceId=3D'container_1481658997383_0003_01_000013'} > failed. Exit > >>> status: Pmem limit exceeded (-104) > >>> Diagnostics for container > >>> ResourceID{resourceId=3D'container_1481658997383_0003_01_000013'} in > state > >>> COMPLETE : exitStatus=3DPmem limit exceeded (-104) diagnostics=3DCont= ainer > >>> [pid=3D21246,containerID=3Dcontainer_1481658997383_0003_01_000013] is > running > >>> beyond physical memory limits. Current usage: 5.6 GB of 5.6 GB physic= al > >>> memory used; 9.6 GB of 28.1 GB virtual memory used. Killing container= . > >>> Container killed on request. Exit code is 143 > >>> Container exited with a non-zero exit code 143 > >>> Total number of failed containers so far: 12 > >>> Stopping YARN session because the number of failed containers (12) > >>> exceeded the maximum failed containers (11). This number is controlle= d > by > >>> the 'yarn.maximum-failed-containers' configuration setting. By > default its > >>> the number of requested containers. > >>> From here onward, the logs repeatedly show that jobs fail to restart > due > >>> to > >>> "org.apache.flink.runtime.jobmanager.scheduler. > NoResourceAvailableException: > >>> Not enough free slots available to run the job. You can decrease the > >>> operator parallelism or increase the number of slots per TaskManager > in the > >>> configuration. Task to schedule: < Attempt #68 (Source: =E2=80=A6) @ > (unassigned) - > >>> [SCHEDULED] > with groupID < 73191c171abfff61fb5102c161274145 > in > sharing > >>> group < SlotSharingGroup [73191c171abfff61fb5102c161274145, > >>> 19596f7834805c8409c419f0edab1f1b] >. Resources available to scheduler= : > >>> Number of instances=3D0, total number of slots=3D0, available slots= =3D0" > >>> Eventually, Flink stops for some reason (with another SIGTERM message= ), > >>> presumably because of YARN > >>> > >>> Does anyone have an idea why a bad job repeatedly failing would > >>> eventually result in the Flink cluster dying? > >>> > >>> Any idea why I'd get "Pmem limit exceeded" or "Not enough free slots > >>> available to run the job"? The JVM heap usage and the free memory on > the > >>> machines both look reasonable in my monitoring dashboards. Could it > possibly > >>> be a memory leak due to classloading or something? > >>> > >>> Thanks for any help or suggestions you can provide! I am hoping that > the > >>> "failure-rate" restart strategy will help avoid this issue in the > future, > >>> but I'd also like to understand what's making the cluster die so that > I can > >>> prevent it. > >>> > >>> -Shannon > >> > >> > > > --001a1143e4ce0f28c60546d7a391 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi!

I think there were some issues in t= he HA recovery of 1.1.3 that were fixed in 1.1.4 and 1.2.0.
What = version are you running on?

Stephan

=

On Sa= t, Jan 21, 2017 at 4:58 PM, Ufuk Celebi <uce@apache.org> wrote:=
Hey Shannon,

the final truth for recovery is in ZooKeeper. Can you check whether
there also references available in ZooKeeper? Do you have the job
manager logs available from after the failure? On recovery, Flink
checks ZooKeeper for entries. These point to files in the storageDir.
It could have happened that these got out of sync, e.g. entries
deleted from ZK but not from the storageDir.

Maybe the loss of the task managers can also be explained by a
connection loss to ZK or something. When a JM looses leadership, the
TMs cancel all tasks and disconnect from the JM. Here again, we would
need to look into the logs.

Sorry for the bad experience lately :-(

=E2=80=93 Ufuk


On Sat, Jan 21, 2017 at 4:31 AM, Shannon Carey <scarey@expedia.com> wrote:
> In fact, I can see all my job jar blobs and some checkpoint & job = graph
> files in my configured "recovery.zookeeper.storageDir"= =E2=80=A6 however for some
> reason it didn't get restored when my new Flink cluster started up= .
>
>
> From: Shannon Carey <scarey@e= xpedia.com>
> Date: Friday, January 20, 2017 at 9:14 PM
> To: "user@flink.apache.o= rg" <user@flink.apache= .org>
>
> Subject: Re: Rapidly failing job eventually causes "Not enough fr= ee slots"
>
> I recently added some better visibility into the metrics we're gat= hering
> from Flink. My Flink cluster died again due to the "Not enough fr= ee slots
> available to run the job" problem, and this time I can see that t= he number
> of registered task managers went down from 11 to 7, then waffled and o= nly
> ever got back up to 10 (one short of the requested amount) before drop= ping
> to 0 just before the cluster died. This would seem to explain why ther= e
> weren't sufficient slots (given that we were probably using them a= ll or
> nearly all)=E2=80=A6 The metric of "running jobs" went down = from 5 to 3 during this
> time period as well. So the problem seems to be loss of taskmanagers d= ue to
> errors (not yet sure what exactly as I have to delve into logs).
>
> The other thing I have to figure out is restoring the jobs=E2=80=A6 I = thought that
> HA would start the jobs back up again if Flink died & I re-launche= d it, but
> that doesn't appear to be the case.
>
>
> From: Stephan Ewen <sewen@apach= e.org>
> Date: Thursday, January 5, 2017 at 7:52 AM
> To: <user@flink.apache.org= >
> Subject: Re: Rapidly failing job eventually causes "Not enough fr= ee slots"
>
> Another thought on the container failure:
>
> in 1.1, the user code is loaded dynamically whenever a Task is started= . That
> means that on every task restart the code is reloaded. For that to wor= k
> proper, class unloading needs to happen, or the permgen will eventuall= y
> overflow.
>
> It can happen that class unloading is prevented if the user functions = do
> leave references around as "GC roots", which may be threads,= or references
> in registries, etc.
>
> In Flink 1.2, YARN will put the user code into the application classpa= th, so
> code needs not be reloaded on every restart. That should solve that is= sue.
> To "simulate" that behavior in Flink 1.1, put your applicati= on code jars
> into the "lib" folder
>
> Best,
> Stephan
>
>
> On Thu, Jan 5, 2017 at 1:15 PM, Yury Ruchin <yuri.ruchin@gmail.com> wrote:
>>
>> Hi,
>>
>> I've faced a similar issue recently. Hope sharing my findings = will help.
>> The problem can be split into 2 parts:
>>
>> Source of container failures
>> The logs you provided indicate that YARN kills its containers for<= br> >> exceeding memory limits. Important point here is that memory limit= =3D JVM
>> heap memory + off-heap memory. So if off-heap memory usage is high= , YARN may
>> kill containers despite JVM heap consumption is fine. To solve thi= s issue,
>> Flink reserves a share of container memory for off-heap memory. Ho= w much
>> will be reserved is controlled by yarn.heap-cutoff-ratio and
>> yarn.heap-cutoff-min configuration. By default 25% of the requeste= d
>> container memory will be reserved for off-heap. This is seems to b= e a good
>> start, but one should experiment and tune to meet their job specif= ics.
>>
>> It's also worthwhile to figure out who consumes off-heap memor= y. Is it
>> Flink managed memory moved off heap (taskmanager.memory.off-heap = =3D true)? Is
>> it some external library allocating something off heap? Is it your= own code?
>>
>> How Flink handles task manager failures
>> Whenever a task manager fails, the Flink jobmanager decides whethe= r it
>> should:
>> - reallocate failed task manager container
>> - fail application entirely
>> These decisions can be guided by certain configuration
>> (https://ci.apache.org/projects/flink/flink-d= ocs-release-1.1/setup/yarn_setup.html#recovery-behavior-of-f= link-on-yarn).
>> With default settings, job manager does reallocate task manager co= ntainers
>> up to the point when N failures have been observed, where N is the= number of
>> requested task managers. After that the application is stopped. >>
>> According to the logs, you have a finite number in
>> yarn.maximum-failed-containers (11, as I can see from the logs - t= his may be
>> set by Flink if not provided explicitly). On 12th container restar= t,
>> jobmanager gives up and the application stops. I'm not sure wh= y it keeps
>> reporting not enough slots after that point. In my experience this= may
>> happen when job eats up all the available slots, so that after con= tainer
>> failure its tasks cannot be restarted in other (live) containers. = But I
>> believe once the decision to stop the application is made, there s= hould not
>> be any further attempts to restart the job, hence no logs like tho= se.
>> Hopefully, someone else will explain this to us :)
>>
>> In my case I made jobmanager restart containers infinitely by sett= ing
>> yarn.maximum-failed-containers =3D -1, so that taskmanager failure= never
>> results in application death. Note this is unlikely a good choice = for a
>> batch job.
>>
>> Regards,
>> Yury
>>
>> 2017-01-05 3:21 GMT+03:00 Shannon Carey <scarey@expedia.com>:
>>>
>>> In Flink 1.1.3 on emr-5.2.0, I've experienced a particular= problem twice
>>> and I'm wondering if anyone has some insight about it.
>>>
>>> In both cases, we deployed a job that fails very frequently (w= ithin
>>> 15s-1m of launch). Eventually, the Flink cluster dies.
>>>
>>> The sequence of events looks something like this:
>>>
>>> bad job is launched
>>> bad job fails & is restarted many times (I didn't have= the "failure-rate"
>>> restart strategy configuration right)
>>> Task manager logs: org.apache.flink.yarn.YarnTaskManagerR= unner (SIGTERM
>>> handler): RECEIVED SIGNAL 15: SIGTERM. Shutting down as reques= ted.
>>> At this point, the YARN resource manager also logs the contain= er failure
>>> More logs: Container
>>> ResourceID{resourceId=3D'container_1481658997383_0003= _01_000013'} failed. Exit
>>> status: Pmem limit exceeded (-104)
>>> Diagnostics for container
>>> ResourceID{resourceId=3D'container_1481658997383_0003= _01_000013'} in state
>>> COMPLETE : exitStatus=3DPmem limit exceeded (-104) diagnostics= =3DContainer
>>> [pid=3D21246,containerID=3Dcontainer_1481658997383_0003_<= wbr>01_000013] is running
>>> beyond physical memory limits. Current usage: 5.6 GB of 5.6 GB= physical
>>> memory used; 9.6 GB of 28.1 GB virtual memory used. Killing co= ntainer.
>>> Container killed on request. Exit code is 143
>>> Container exited with a non-zero exit code 143
>>> Total number of failed containers so far: 12
>>> Stopping YARN session because the number of failed containers = (12)
>>> exceeded the maximum failed containers (11). This number is co= ntrolled by
>>> the 'yarn.maximum-failed-containers' configuratio= n setting. By default its
>>> the number of requested containers.
>>> From here onward, the logs repeatedly show that jobs fail to r= estart due
>>> to
>>> "org.apache.flink.runtime.jobmanager.scheduler.= NoResourceAvailableException:
>>> Not enough free slots available to run the job. You can decrea= se the
>>> operator parallelism or increase the number of slots per TaskM= anager in the
>>> configuration. Task to schedule: < Attempt #68 (Source: =E2= =80=A6) @ (unassigned) -
>>> [SCHEDULED] > with groupID < 73191c171abfff61fb5102c1612= 74145 > in sharing
>>> group < SlotSharingGroup [73191c171abfff61fb5102c16127= 4145,
>>> 19596f7834805c8409c419f0edab1f1b] >. Resources availab= le to scheduler:
>>> Number of instances=3D0, total number of slots=3D0, available = slots=3D0"
>>> Eventually, Flink stops for some reason (with another SIGTERM = message),
>>> presumably because of YARN
>>>
>>> Does anyone have an idea why a bad job repeatedly failing woul= d
>>> eventually result in the Flink cluster dying?
>>>
>>> Any idea why I'd get "Pmem limit exceeded" or &q= uot;Not enough free slots
>>> available to run the job"? The JVM heap usage and the fre= e memory on the
>>> machines both look reasonable in my monitoring dashboards. Cou= ld it possibly
>>> be a memory leak due to classloading or something?
>>>
>>> Thanks for any help or suggestions you can provide! I am hopin= g that the
>>> "failure-rate" restart strategy will help avoid this= issue in the future,
>>> but I'd also like to understand what's making the clus= ter die so that I can
>>> prevent it.
>>>
>>> -Shannon
>>
>>
>

--001a1143e4ce0f28c60546d7a391--