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

Duplicate state created #9093

Open
jerviscui opened this issue Jul 31, 2024 · 1 comment
Open

Duplicate state created #9093

jerviscui opened this issue Jul 31, 2024 · 1 comment

Comments

@jerviscui
Copy link

IGrainState creates the state through IActivatorProvider.
IGrainStorage.ReadStateAsync uses Activator.CreateInstance() to create the state once again when there is no data in the stage.
And even if it is created again, it should be created using the IActivatorProvider to keep the logic consistent?

@jerviscui
Copy link
Author

IGrainStorage.ReadStateAsync:

T state = readRecords != null ? (T) readRecords.Item1 : default;
string etag = readRecords != null ? readRecords.Item2 : null;
bool recordExists = readRecords != null;
if(state == null)
{
    logger.LogInformation(
        (int)RelationalStorageProviderCodes.RelationalProviderNoStateFound,
        "Null grain state read (default will be instantiated): ServiceId={ServiceId} ProviderName={Name} GrainType={BaseGrainType} GrainId={GrainId} ETag={ETag}.",
        serviceId,
        name,
        baseGrainType,
        grainId,
        grainState.ETag);
    state = Activator.CreateInstance<T>();
}

grainState.State = state;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant