You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently working with ITransactionalState using memory storage in Orleans.
I encountered a problem where PerformRead appears not to reflect the state updated by a previous PerformUpdate call within the same Grain method.
Here's a simplified version of my setup:
Grain state:
[GenerateSerializer]
public record class Balance
{
[Id(0)]
public int Value { get; init; } = 1000;
}
Grain Implementation:
[Reentrant]
public class AccountGrain : Grain, IAccountGrain
{
private readonly ITransactionalState<Balance> _balance;
public AccountGrain(
[TransactionalState("balance")] ITransactionalState<Balance> balance) =>
_balance = balance ?? throw new ArgumentNullException(nameof(balance));
public Task Deposit(int amount) =>
_balance.PerformUpdate(
balance => balance with { Value = balance.Value + amount });
public Task<int> GetBalance() =>
_balance.PerformRead(balance => balance.Value);
}
Expected:
I expected the PerformRead to reflect the updated state after the PerformUpdate.
Actual:
PerformRead consistently returns the initial value (1000), even after calling PerformUpdate in the same method.
I also tried calling PerformRead inside the same transaction from a client (RunTransaction), but got the same behavior
Is there something I'm missing about how PerformRead should behave inside the Grain itself after an update?
Or is this expected behavior under some isolation semantics?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi Orleans team 👋
I'm currently working with ITransactionalState using memory storage in Orleans.
I encountered a problem where PerformRead appears not to reflect the state updated by a previous PerformUpdate call within the same Grain method.
Here's a simplified version of my setup:
Grain state:
Grain Implementation:
Expected:
I expected the PerformRead to reflect the updated state after the PerformUpdate.
Actual:
PerformRead consistently returns the initial value (1000), even after calling PerformUpdate in the same method.
All Code:
https://github.com/jaeunify/sampleOrleans
Silo setup:
Other context:
Nuget Orleans SDK version: 9.1.2
I'm testing with a fixed Grain ID ("default")
I also tried calling PerformRead inside the same transaction from a client (RunTransaction), but got the same behavior
Is there something I'm missing about how PerformRead should behave inside the Grain itself after an update?
Or is this expected behavior under some isolation semantics?
Thanks in advance 🙏
Beta Was this translation helpful? Give feedback.
All reactions