Flink: possible to delete Queryable state after X time?

廉价感情. 提交于 2020-01-03 02:56:07

问题


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

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.

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


回答1:


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.

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.



来源:https://stackoverflow.com/questions/54330034/flink-possible-to-delete-queryable-state-after-x-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!