You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-zh@flink.apache.org by "wanglei2@geekplus.com.cn" <wa...@geekplus.com.cn> on 2019/12/10 02:16:38 UTC

Re: Re: Flink State 过期清除 TTL 问题

Hi 唐云,

我的集群已经升到了 1.8.2,  cleanupFullSnapshot 和 cleanupInRocksdbCompactFilter 都试验了下。
但 cancel -s 停止后, 生成的 savepoint 目录还是没有变小。过程是这样的:

cancel -s 停止,savepoint 目录大小为 100M
代码变更,把原来的 setUpdateType 变为 cleanupFullSnapshot 
新的代码从 1 的 savepoint 目录恢复
新的代码运行一天左右,再 cancel -s, 新的 savepoint 目录变大

会不会是 每次 flink run -s ,从已有 savepoint 目录中恢复的数据所有的 updateTime 都变成了当前时间? 

谢谢,
王磊



wanglei2@geekplus.com.cn
 
Sender: Yun Tang
Send Time: 2019-11-01 01:38
Receiver: user-zh@flink.apache.org
Subject: Re: Flink State 过期清除 TTL 问题
Hi 王磊
 
从你的配置以及使用Flink-1.7版本看,并没有启用主动清理过期数据的功能 [1],建议对StateTtlConfig 配置 cleanupFullSnapshot,这样你在执行full snapshot(也就是Savepoint)的时候,会把过期的数据不保存在你的Savepoint内容中。如果你不启用主动清理,只有当原先的数据被读取时,才会进行清理,这可能就导致你的Savepoint内容不断增长的原因。
 
另外,建议升级到Flink-1.8+,对state TTL的特性支持更好,可以参考中文文章 [2]
 
[1] https://ci.apache.org/projects/flink/flink-docs-release-1.7/dev/stream/state/state.html#cleanup-of-expired-state
[2] https://www.infoq.cn/article/L_66ga2G9oLWypvOLtIv
 
祝好
唐云
 
 
On 10/31/19, 10:25 AM, "wanglei2@geekplus.com.cn" <wa...@geekplus.com.cn> wrote:
 
    flink-1.7.2, 用下面的清除策略:StateTtlConfig ttlConfig = StateTtlConfig
            .newBuilder(Time.days(3)).setUpdateType(StateTtlConfig.UpdateType.OnCreateAndWrite).setStateVisibility(StateTtlConfig.StateVisibility.NeverReturnExpired).build();
    ValueStateDescriptor<OrderState> descriptor = new ValueStateDescriptor("OrderState", TypeInformation.of(OrderState.class));
    descriptor.enableTimeToLive(ttlConfig);
    
    程序更新时用 savepoint 的方式, flink cancel -s 保存到 savepoint 目录,再从 savepoint 目录恢复。
    我的程序运行了一段时间,已经远大于 3 天,每次 flink cancel -s 后生成的 savepoint 目录不断变大。是过期清除策略没生效吗?
    
    谢谢,
    王磊
    
    
    
    wanglei2@geekplus.com.cn