Repository navigation
feat(transactions): add read-committed reads to ITransactionalState - #11615
scalalang2 wants to merge 1 commit into
Conversation
Add ReadIsolation and a PerformRead overload that returns the most recently committed state without starting a transaction, taking a lock, or writing to storage. A read-committed read is rejected inside an ambient transaction because the snapshot is outside that transaction's locks and would break serializability. Adding interface members is an intentional break against the 10.4.0 package baseline, so CompatibilitySuppressions.xml is added for Orleans.Transactions and Orleans.Transactions.TestKit.Base. Closes dotnet#11611
Code coverage
Report-only conclusion: improved. The current-main baseline is commit Coverage combines every CI test matrix job, including providers, CodeGen, .NET 8/10, Linux, Windows, and macOS, using canonical physical source and branch identities. The comparison remains report-only while normal line and branch variance is calibrated. Coverage details |
There was a problem hiding this comment.
🟡 Changes recommended
The new read path lacks a deterministic test proving nonblocking reads of the previous committed value during a pending write that later aborts, and its public documentation omits mutation restrictions and visibility-lag caveats.
3 open issues
What changed in this PR
Adds non-transactional committed reads to Orleans transactional state, addressing #11611 by avoiding the storage writes required by read-only transactions.
Changes:
- Adds
ReadIsolationand aPerformReadoverload using the locally committed snapshot, with ambient-transaction rejection. - Extends transaction test grains and runners to check committed reads and transaction rejection.
- Updates generated API surfaces, grain contracts, and compatibility suppressions for the intentional interface additions.
| File | Description |
|---|---|
test/Transactions/Orleans.Transactions.Tests/TransactionCoordinatorInputValidationTests.cs |
Adds the committed-read test stub. |
test/Transactions/Orleans.Transactions.Tests/FaultInjectionTransactionalStateAttributeMapperTests.cs |
Updates the recording state for the overload. |
test/Transactions/Orleans.Transactions.Tests/ExclusiveLockCoordinatorInputValidationTests.cs |
Adds unexpected-call handling for committed reads. |
test/Transactions/Orleans.Transactions.Tests/ConsistencyTestGrainInputValidationTests.cs |
Updates the state test double. |
src/Orleans.Transactions/State/TransactionQueue.cs |
Exposes the stable committed snapshot. |
src/Orleans.Transactions/State/TransactionalState.cs |
Implements isolation selection and committed reads. |
src/Orleans.Transactions/CompatibilitySuppressions.xml |
Records the intentional interface compatibility break. |
src/Orleans.Transactions/Abstractions/ReadIsolation.cs |
Defines public read isolation options. |
src/Orleans.Transactions/Abstractions/ITransactionalState.cs |
Adds the isolation-aware read contract. |
src/Orleans.Transactions.TestKit.xUnit/GoldenPathTransactionTestRunner.cs |
Exposes new scenarios as xUnit theories. |
src/Orleans.Transactions.TestKit.Base/TestRunners/GoldenPathTransactionTestRunner.cs |
Tests committed values and ambient-transaction rejection. |
src/Orleans.Transactions.TestKit.Base/OrleansContracts.txt |
Records new grain methods and refreshes regeneration comments. |
src/Orleans.Transactions.TestKit.Base/Grains/TransactionCoordinatorGrain.cs |
Invokes committed reads inside a transaction. |
src/Orleans.Transactions.TestKit.Base/Grains/MultiStateTransactionalGrain.cs |
Reads committed values across grain states. |
src/Orleans.Transactions.TestKit.Base/Grains/ITransactionTestGrain.cs |
Declares the committed-read grain method. |
src/Orleans.Transactions.TestKit.Base/Grains/ITransactionCoordinatorGrain.cs |
Declares the transaction-rejection test entry point. |
src/Orleans.Transactions.TestKit.Base/FaultInjection/ControlledInjection/FaultInjectionTransactionState.cs |
Forwards the isolation-aware overload. |
src/Orleans.Transactions.TestKit.Base/CompatibilitySuppressions.xml |
Records intentional test-grain interface breaks. |
src/api/Orleans.Transactions/Orleans.Transactions.cs |
Updates the generated transaction API surface. |
src/api/Orleans.Transactions.TestKit.xUnit/Orleans.Transactions.TestKit.xUnit.cs |
Refreshes generated test APIs and attributes. |
src/api/Orleans.Transactions.TestKit.Base/Orleans.Transactions.TestKit.Base.cs |
Updates generated test-kit APIs and invocation types. |
Review effort: Balanced
|
|
||
| await this.queue.Ready(); | ||
|
|
||
| this.queue.GetCommittedState(out var state, out var sequenceNumber); |
| /// Performs a read operation with the specified isolation and returns the result. | ||
| /// </summary> | ||
| /// <typeparam name="TResult">The result type.</typeparam> | ||
| /// <param name="readFunction">A function that reads the state and returns the result.</param> |
| /// Reads the most recently committed state without a transaction, lock, or storage write. | ||
| /// Rejected when an ambient transaction exists. |


Disclaimer:
This code was written by Claude Fable 5. but I reviewed it myself.
Add
ReadIsolationand aPerformRead overloadthat returns the most recently committed state without starting a transaction, taking a lock, or writing to storage. A read-committed read is rejected inside an ambient transaction because the snapshot is outside that transaction's locks and would break serializability.Adding interface members is an intentional break against the 10.4.0 package baseline, so CompatibilitySuppressions.xml is added for Orleans.Transactions and Orleans.Transactions.TestKit.Base.
Closes #11611
Microsoft Reviewers: Open in CodeFlow