DataStream的state问题

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

DataStream的state问题

ゞ野蠻遊戲χ
Deal all:


想问下,在给state设置ttl的时候,如下面的代码:                    StateTtlConfig ttlConfig = StateTtlConfig
                            .newBuilder(Time.days(1))
                            .setUpdateType(StateTtlConfig.UpdateType.OnCreateAndWrite)
                            .setStateVisibility(StateTtlConfig.StateVisibility.NeverReturnExpired)
                            .build();



设置了1天时间之后失效,例如2020-07-07 08:30:00点开始的job,那失效时间是这个时间段2020-07-07 00:00:00~2020-07-07 23:59:59,还是job上线之后,2020-07-07 08:30:00~2020-07-08 08:30:00这个时间段?


Thanks
Jiazhi
Reply | Threaded
Open this post in threaded view
|

Re: DataStream的state问题

Congxian Qiu
Hi

是最后一次 access 的时间到当前的时间超过了你设置的 ttl 间隔,比如你配置的是 `OnCreateAndWrite`
那么就是创建和写操作之后的 1 天,这个 state 会变成 expired,具体的可以参考文档[1]

[1]
https://ci.apache.org/projects/flink/flink-docs-release-1.10/zh/dev/stream/state/state.html#%E7%8A%B6%E6%80%81%E6%9C%89%E6%95%88%E6%9C%9F-ttl
Best,
Congxian


ゞ野蠻遊戲χ <[hidden email]> 于2020年7月7日周二 下午12:17写道:

> Deal all:
>
>
> 想问下,在给state设置ttl的时候,如下面的代码:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
> &nbsp; &nbsp; &nbsp; &nbsp; StateTtlConfig ttlConfig = StateTtlConfig
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
> &nbsp; &nbsp; &nbsp; &nbsp; .newBuilder(Time.days(1))
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
> &nbsp; &nbsp; &nbsp; &nbsp;
> .setUpdateType(StateTtlConfig.UpdateType.OnCreateAndWrite)
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
> &nbsp; &nbsp; &nbsp; &nbsp;
> .setStateVisibility(StateTtlConfig.StateVisibility.NeverReturnExpired)
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
> &nbsp; &nbsp; &nbsp; &nbsp; .build();
>
>
>
> 设置了1天时间之后失效,例如2020-07-07 08:30:00点开始的job,那失效时间是这个时间段2020-07-07
> 00:00:00~2020-07-07 23:59:59,还是job上线之后,2020-07-07 08:30:00~2020-07-08
> 08:30:00这个时间段?
>
>
> Thanks
> Jiazhi