Flink:是否可以在X时间之后删除Queryable状态? [英] Flink: possible to delete Queryable state after X time?

查看:168
本文介绍了Flink:是否可以在X时间之后删除Queryable状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

就我而言,我仅使用Flink的可查询状态.特别是,我不在乎检查点.

In my case, I use Flink's queryable state only. In particular, I do not care about checkpoints.

在发生事件时,我最多只能在X分钟后查询可查询状态.理想情况下,我将删除旧"状态以节省空间.

Upon an event, I query the queryable state only after a maximum of X minutes. Ideally, I would delete the "old" state to save on space.

这就是为什么我想知道:我可以在一段时间后发出Flink的状态以清除自身的信号吗?通过配置?通过特定的事件信号?怎么样?

That's why I wonder: can I signal Flink's state to clear itself after some time? Through configuration? Through specific event signals? How?

推荐答案

清除状态的一种方法是,当您不再需要特定键时,在状态对象(例如ValueState对象)上显式调用clear() .通常是在ProcessFunctiononTimer()回调中完成的.

One way to clear state is to explicitly call clear() on the state object (e.g., a ValueState object) when you no longer need it for a particular key. This is typically done in an onTimer() callback in a ProcessFunction.

另一种可能的方法是使用

Another possible approach would be to use state time-to-live to manage its lifecycle.

我还没有尝试过将状态TTL与可查询状态一起使用,但是我看不出它为什么不起作用的任何原因.但是,从Flink 1.7开始,状态TTL仅在访问状态(对于该键)或进行完整的状态快照时才真正清除状态(对于键).因此,在您的特定情况下,这种状态TTL机制可能不是很有用.

I haven't tried using state TTL with queryable state, but I can't see any reason why it shouldn't work. However, as of Flink 1.7, state TTL only actually clears state (for a key) when the state is accessed (for that key), or when taking a full state snapshot. So in your particular case, this state TTL mechanism may not be very useful.

这篇关于Flink:是否可以在X时间之后删除Queryable状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆