Flink akka AskTimeoutException问题排查

最近遇到一个很奇怪的问题,Flink任务正常启动正常运行一段时间后就会报错,,错误详情如下

2019-12-11 17:20:57.757 flink [flink-scheduler-1] ERROR o.apache.flink.runtime.rest.handler.job.JobsOverviewHandler - Unhandled exception.akka.pattern.AskTimeoutException: Ask timed out on [Actor[akka://flink/user/dispatcher#761962841]] after [10000 ms]. Sender[null] sent message of type "org.apache.flink.runtime.rpc.messages.LocalFencedMessage".
    at akka.pattern.PromiseActorRef$$anonfun$1.apply$mcV$sp(AskSupport.scala:604)
    at akka.actor.Scheduler$$anon$4.run(Scheduler.scala:126)
    at scala.concurrent.Future$InternalCallbackExecutor$.unbatchedExecute(Future.scala:601)
    at scala.concurrent.BatchingExecutor$class.execute(BatchingExecutor.scala:109)
    at scala.concurrent.Future$InternalCallbackExecutor$.execute(Future.scala:599)
    at akka.actor.LightArrayRevolverScheduler$TaskHolder.executeTask(LightArrayRevolverScheduler.scala:329)
    at akka.actor.LightArrayRevolverScheduler$$anon$4.executeBucket$1(LightArrayRevolverScheduler.scala:280)
    at akka.actor.LightArrayRevolverScheduler$$anon$4.nextTick(LightArrayRevolverScheduler.scala:284)
    at akka.actor.LightArrayRevolverScheduler$$anon$4.run(LightArrayRevolverScheduler.scala:236)
    at java.lang.Thread.run(Thread.java:745)

初步判断应该是触发了akka的超时机制,那就先调整集群的akka超时间配置,在conf/flink-conf.yaml最后增加下面参数

akka.ask.timeout: 100 s

观察Job Manager Configuration,配置参数已经生效

再将任务起起来,在运行十几个小时之后还是出现同样的错误,这就很奇怪了,明明更改了参数也生效了,为啥还是10000 ms就超时了

似乎有点邪门,只能Google一把了,在Apache Flink 中文用户邮件列表找到类似的问题,给出的建议是调整akka.ask.timeout和web.timeout两个参数

异常原因如上所说是 akka ask timeout 的问题,这个问题前两天有人在部署 k8s 的时候也遇过[1]

他的情况是配置资源过少导致 JM 未能及时响应。除了调整上述参数外也可看看是不是这个问题。

Best,
tison.

[1]
https://lists.apache.org/thread.html/84db9dca2e990dd0ebc30aa35390ac75a0e9c7cbfcdbc2029986d4d7@%3Cuser-zh.flink.apache.org%3E


Biao Liu <[hidden email]> 于2019年8月8日周四 下午8:00写道:

> 你好,
>
> 异常里可以看出 AskTimeoutException, 可以调整两个参数 akka.ask.timeout 和 web.timeout
> 再试一下,默认值如下
>
> akka.ask.timeout: 10 s
> web.timeout: 10000
>
> PS: 搜 “AskTimeoutException Flink” 可以搜到很多相关答案
>
> Thanks,
> Biao /'bɪ.aʊ/

这我就有点奇怪了,错误和web.timeout有啥关系啊,只能顺着错误翻看Flink源码了。在源码重直接找到JobsOverviewHandler类,发现引用这个类就两个:一个是JobsOverviewHeaders,主要是作为一个link;另外一个是WebMonitorEndpoint,

在这实例化了一个JobsOverviewHandler,传入了timeout参数

protected final RestHandlerConfiguration restConfiguration;

final Time timeout = restConfiguration.getTimeout();

JobsOverviewHandler jobsOverviewHandler = new JobsOverviewHandler(leaderRetriever,timeout,responseHeaders,JobsOverviewHeaders.getInstance());

再追踪timeout来源发现取自RestHandlerConfiguration Timeout字段,而这个值来自WebOptions.TIMEOUT

    public static RestHandlerConfiguration fromConfiguration(Configuration configuration) {
        final long refreshInterval = configuration.getLong(WebOptions.REFRESH_INTERVAL);

        final int maxCheckpointStatisticCacheEntries = configuration.getInteger(WebOptions.CHECKPOINTS_HISTORY_SIZE);

        final Time timeout = Time.milliseconds(configuration.getLong(WebOptions.TIMEOUT));

        final String rootDir = "flink-web-ui";
        final File webUiDir = new File(configuration.getString(WebOptions.TMP_DIR), rootDir);

        return new RestHandlerConfiguration(
            refreshInterval,
            maxCheckpointStatisticCacheEntries,
            timeout,
            webUiDir);
    }

    /**
     * Timeout for asynchronous operations by the web monitor in milliseconds.
     */
    public static final ConfigOption<Long> TIMEOUT =
        key("web.timeout")
        .defaultValue(10L * 1000L)
        .withDescription("Timeout for asynchronous operations by the web monitor in milliseconds.");

这下真相大白,果然需要调整web.timeout参数,是web监视器的异步操作超时时间,默认10000ms。将该值提高到300000ms,继续观察。

 

参考

https://zhuanlan.zhihu.com/p/49095640

http://apache-flink.147419.n8.nabble.com/Fwd-need-help-td321.html#a349

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章