You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by narasimha <sw...@gmail.com> on 2021/08/31 01:44:34 UTC

Delete Keyed State outside of StateTTL

Hi,

I have a use case where the keyed state is managed (create, reset) by
dynamically changing rules. New action "delete" has to be added.
Delete is to completely delete the keyed state, same as how StateTTL does
post expiration time.

Use StateTTL?

Initially used StateTTL, but it ended up in increasing the CPU usage even
with low traffic.
The state gets updated ~>50 times a second, and read multiple times in a
second, so the time against state entry is getting updated often.

So I didn't find it to be a viable solution.

Can someone please help on how Keyed State can be removed outside of
StateTTL.

-- 
A.Narasimha Swamy

Re: Delete Keyed State outside of StateTTL

Posted by JING ZHANG <be...@gmail.com>.
Hi,
After you call `clear()`, you could be sure that they would not be returned
when you query the state under the key. The state would be removed.
The implication on memory occupation depends on which state backend.
Different state backend may have different implication here.
For example, if you use heap state backend, the entry would be removed from
heap directly, so the memory occupation would be reduced.

narasimha <sw...@gmail.com> 于2021年8月31日周二 下午12:16写道:

> Thank JING.
>
> But I have a question here, what will happen to the keyed stream in that
> case?  Will it be removed automatically? or will be present but the state
> will be empty, in that case what is the implication on memory occupation?
>
> On Tue, Aug 31, 2021 at 8:14 AM JING ZHANG <be...@gmail.com> wrote:
>
>> Hi,
>> All types of state also have a method clear() that clears the state for
>> the currently active key, i.e. the key of the input element.
>> Could we call the `clear()` method directly to remove the state under the
>> specified key?
>>
>> Best,
>> JING ZHANG
>>
>>
>> narasimha <sw...@gmail.com> 于2021年8月31日周二 上午9:44写道:
>>
>>> Hi,
>>>
>>> I have a use case where the keyed state is managed (create, reset) by
>>> dynamically changing rules. New action "delete" has to be added.
>>> Delete is to completely delete the keyed state, same as how StateTTL
>>> does post expiration time.
>>>
>>> Use StateTTL?
>>>
>>> Initially used StateTTL, but it ended up in increasing the CPU usage
>>> even with low traffic.
>>> The state gets updated ~>50 times a second, and read multiple times in a
>>> second, so the time against state entry is getting updated often.
>>>
>>> So I didn't find it to be a viable solution.
>>>
>>> Can someone please help on how Keyed State can be removed outside of
>>> StateTTL.
>>>
>>> --
>>> A.Narasimha Swamy
>>>
>>
>
> --
> A.Narasimha Swamy
>

Re: Delete Keyed State outside of StateTTL

Posted by narasimha <sw...@gmail.com>.
Thank JING.

But I have a question here, what will happen to the keyed stream in that
case?  Will it be removed automatically? or will be present but the state
will be empty, in that case what is the implication on memory occupation?

On Tue, Aug 31, 2021 at 8:14 AM JING ZHANG <be...@gmail.com> wrote:

> Hi,
> All types of state also have a method clear() that clears the state for
> the currently active key, i.e. the key of the input element.
> Could we call the `clear()` method directly to remove the state under the
> specified key?
>
> Best,
> JING ZHANG
>
>
> narasimha <sw...@gmail.com> 于2021年8月31日周二 上午9:44写道:
>
>> Hi,
>>
>> I have a use case where the keyed state is managed (create, reset) by
>> dynamically changing rules. New action "delete" has to be added.
>> Delete is to completely delete the keyed state, same as how StateTTL does
>> post expiration time.
>>
>> Use StateTTL?
>>
>> Initially used StateTTL, but it ended up in increasing the CPU usage even
>> with low traffic.
>> The state gets updated ~>50 times a second, and read multiple times in a
>> second, so the time against state entry is getting updated often.
>>
>> So I didn't find it to be a viable solution.
>>
>> Can someone please help on how Keyed State can be removed outside of
>> StateTTL.
>>
>> --
>> A.Narasimha Swamy
>>
>

-- 
A.Narasimha Swamy

Re: Delete Keyed State outside of StateTTL

Posted by JING ZHANG <be...@gmail.com>.
Hi,
All types of state also have a method clear() that clears the state for the
currently active key, i.e. the key of the input element.
Could we call the `clear()` method directly to remove the state under the
specified key?

Best,
JING ZHANG


narasimha <sw...@gmail.com> 于2021年8月31日周二 上午9:44写道:

> Hi,
>
> I have a use case where the keyed state is managed (create, reset) by
> dynamically changing rules. New action "delete" has to be added.
> Delete is to completely delete the keyed state, same as how StateTTL does
> post expiration time.
>
> Use StateTTL?
>
> Initially used StateTTL, but it ended up in increasing the CPU usage even
> with low traffic.
> The state gets updated ~>50 times a second, and read multiple times in a
> second, so the time against state entry is getting updated often.
>
> So I didn't find it to be a viable solution.
>
> Can someone please help on how Keyed State can be removed outside of
> StateTTL.
>
> --
> A.Narasimha Swamy
>