-
Notifications
You must be signed in to change notification settings - Fork 171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Actor state manager does not invalidate tracker after SetWithTTL
#406
Comments
The problem here is that SDKs optimistically cache all actor state since an instance will assume an actor's identity for the lifetime of the instance or actor. With the introduction of actor state TTL, SDK caches do not currently reflect the real state as described by the DB (really this is Dapr runtime), i.e. if a key has passed its TTL and been deleted in the DB, it will not be deleted in the cache. There are a few options we have to alleviate this problem in SDKs:
I am probably in favor of 3 the most, though we might want to do 4 as well anyway to prevent actor SDKs themselves ballooning in memory over time as stale state is never cleaned up. /cc @artursouza @yaron2 |
This is a critical thing to be fixed. The SDK should implement option 3. In addition, for applications that cannot afford the inconsistency, it should allow (via config of the actor runtime in SDK) to not cache state anymore. We also need to update documentation explaining the side effects of using TTL for actor state. |
Option 3 is the best path forward. We shouldn't remove caching from the actor clients, it was put in there in the first place due to the low latency and stateful nature of actors (interacting with state in almost every call). |
Describe the bug
In the actor state store,
Get
/Contains
return invalid data after saving a state withSetWithTTL
and waiting for TTL time.t.GetStateManager().SetWithTTL
introduced by #383 is able to save the actual data into the state store with the correct TTL.Here is the screenshot from my Redis DB showing a TTL on the right side.
However, the internal state manager state is likely corrupted. On calling
Contains
orGet
after the TTL has expired, it still returns the old key. This might be possibly due to the fact that in actor/state/state_manager.go, we update thestateChangeTracker
whenSetWithTTL
is called, and in theGet
orContains
method, we only check forRemove
d state, and never look at the TTL. This cache is not invalidated when the TTL expires.To Reproduce
Here is the test plan
Output:
Expected behavior
Get
/Contains
should not return the data if its TTL has expired.The text was updated successfully, but these errors were encountered: