Skip to content
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

Reminder's state manager stale value with more than one run through #784

Open
tstojecki opened this issue Nov 22, 2021 · 6 comments
Open
Labels
kind/bug Something isn't working

Comments

@tstojecki
Copy link

tstojecki commented Nov 22, 2021

Expected Behavior

Reminder that goes beyond one cycle (isn't removed after one single run through) should get an update to state eventually.

Actual Behavior

Reminder never receives an updated state if state is updated following the first run through.

Steps to Reproduce the Problem

Run example/actor demo app. Modify so that state is updated by ActorClient once the reminder had a chance to read state at least once. Notice how on subsequent runs (second, third, etc...) even though the reminder calls StateManager.GetStateAsync<> it never gets an update.

Repo showing code changes to reproduce:
https://github.com/tstojecki/dotnet-sdk/commits/reminder-stale-cache-state-bug

Release Note

RELEASE NOTE:
FIX Bug in reminder's state manager never getting an updated state.

@tstojecki tstojecki added the kind/bug Something isn't working label Nov 22, 2021
@tstojecki
Copy link
Author

tstojecki commented Nov 23, 2021

It has to do with the internal state tracker context inside ActorStateManager.cs - appears to be some sort of per request caching mechanism? Basically the reminder is unaware of subsequent updates to the state as StateManager continues to return the value stored/cached in tracker context.

One workaround is to call StateManager.ClearCacheAsync() as that internally clears the dictionary before StateManager.GetStateAsync<>

@bitTobiasMeier
Copy link

I detected the same problem. After restarting the service the correct value will be loaded in the reminder also.

@halspang halspang added this to the v1.7 milestone Jan 25, 2022
@halspang halspang modified the milestones: v1.7, v1.8 Mar 29, 2022
@halspang
Copy link
Contributor

@tstojecki - Is this still relevant? I just tried to repro it but was not able to do so.

@halspang halspang modified the milestones: v1.8, Investigations Jun 24, 2022
@halspang
Copy link
Contributor

@tstojecki - Let me know if you're still experiencing any issues or can provide a repro.

@tstojecki
Copy link
Author

@halspang the repro has been provided in the first post, please see above. I recall that this was a very basic modification of the sample from the dapr repo, meaning we didn't create anything complex to run into this.

It could be that this has been fixed by now. In fact I would be surprised if it wasn't given that it sounds like new workflow building block will rely on reminders. So if you want to run the repro and find that it works fine with the latest dapr code, feel free to close this issue.

We had to use another approach due to timing constraints.

@greensebastian
Copy link

I just encountered this problem on 1.13. This call returns different state trackers, as the actor invocation has a context id and value, whereas the reminder does not, so get's the default tracker.

private Dictionary<string, StateMetadata> GetContextualStateTracker()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants