Repository navigation
Fix race condition in TransactionInfo.Fork PendingCalls increment - #9702
ReubenBond merged 1 commit into
Conversation
|
Hi @bknote71, it's not clear to me that multi-threading within a |
|
I think removing Task.Run would nor raise the error. It seems that you expect all code within the transaction to be executed on a single thread. I'm just curious What are the main concerns with allowing multi threading in this context? |
|
The main concern would be whether we need to add more extensive locking or other logic to ensure that it works as intended, and then that logic being shared wit the grain side which is already single threaded (which would be ok, ultimately). |
|
Thank you for your response. So, to clarify, does this mean that the method passed into the TransactionClient is expected to run in a single-threaded manner? By the way, I’m also wondering why the joined field in TransactionInfo is a ConcurrentQueue. That seems to suggest it was designed with multi-threaded access in mind. |
No, you're right, the original intention was for some limited form of concurrent access. As an aside, this should probably be a regular The PR looks good to me. I followed the other code paths and there doesn't appear to be any additional protections needed for your scenario (concurrency on the client) to be supported. |
7d2738f to
d3f3233
Compare
* retire and purge state machines * Update src/Orleans.Journaling/StateMachineManager.cs Co-authored-by: Reuben Bond <[email protected]> * move comments up * wip * time-based retirement logic * last touches * remove test project * remove unused usings * prevent duplicate key error during state machine resurrection * ensure buffered data is re-applied if machine comes back * remove hacky assertion in tests * Update src/Orleans.Journaling/StateMachineManager.cs Co-authored-by: Copilot <[email protected]> * Update src/Orleans.Journaling/StateMachineManager.cs Co-authored-by: Copilot <[email protected]> * Update test/Orleans.Journaling.Tests/StateMachineManagerTests.cs Co-authored-by: Copilot <[email protected]> * Update test/Orleans.Journaling.Tests/StateMachineManagerTests.cs Co-authored-by: Copilot <[email protected]> * Update test/Orleans.Journaling.Tests/StateMachineManagerTests.cs Co-authored-by: Copilot <[email protected]> * Fix table creation logging to reflect existing tables correctly (#9696) The `CreateIfNotExistsAsync` method's response will have a 409-statuscode if the table already exists and will always return the `TableItem` if the call is successful. * Fix ZooKeeper CI tests: correct service name and use official Docker image (#9699) * Initial plan * Fix ZooKeeper CI tests: correct service name and use specific image tag Co-authored-by: ReubenBond <[email protected]> * Use official ZooKeeper Docker image instead of bitnami Co-authored-by: ReubenBond <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: ReubenBond <[email protected]> * Fix Consul CI tests by using compatible Consul version (#9701) * Fix Consul key format to comply with allowed characters Co-authored-by: ReubenBond <[email protected]> * Use custom encoding for Consul keys instead of URL encoding Co-authored-by: ReubenBond <[email protected]> * Simplify encoding logic to handle both IPv4 and IPv6 Co-authored-by: ReubenBond <[email protected]> * Revert breaking changes and use older Consul version for tests Co-authored-by: ReubenBond <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: ReubenBond <[email protected]> * Remove explicit ActivityStatusCode.Ok setting to comply with OpenTelemetry specification (#9703) * Initial plan * Remove explicit ActivityStatusCode.Ok per OpenTelemetry spec Co-authored-by: ReubenBond <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: ReubenBond <[email protected]> * chore(deps): bump dotnet-sdk from 9.0.303 to 9.0.305 (#9677) Bumps [dotnet-sdk](https://github.com/dotnet/sdk) from 9.0.303 to 9.0.305. - [Release notes](https://github.com/dotnet/sdk/releases) - [Commits](dotnet/sdk@v9.0.303...v9.0.305) --- updated-dependencies: - dependency-name: dotnet-sdk dependency-version: 9.0.305 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Fix race condition in `TransactionInfo.Fork` `PendingCalls` increment (#9702) * [FIX] Potential NRE in the activation repartitioner (#9713) fix potentiall NRE in the activation repartioner * Remove infinite timespan reminder checks (#9715) * Timeout.InfiniteTimeSpan is not allowed for reminders * Specifically check for InfiniteTimeSpan to make clear it's usage is not allowed (and to allow for an eventual future change of the InfiniteTimeSpan value) --------- Co-authored-by: Jerremy Koot <[email protected]> * ResponseCompletionSource: RunContinuationsAsynchronously (#9724) * chore(deps): bump dotnet-sdk from 9.0.305 to 9.0.306 (#9720) Bumps [dotnet-sdk](https://github.com/dotnet/sdk) from 9.0.305 to 9.0.306. - [Release notes](https://github.com/dotnet/sdk/releases) - [Commits](dotnet/sdk@v9.0.305...v9.0.306) --- updated-dependencies: - dependency-name: dotnet-sdk dependency-version: 9.0.306 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Add `BigInteger` codec (#9669) * StateMachineManager: start work loop during activation (#9725) * Flag PostgreSQL as asynchronous (#9705) Changed isSynchronousAdoNetImplementation from true to false for PostgreSQL thanks to updates in Npgsql 8.0. npgsql/npgsql#1130 * Enable GitHub merge queue (#9727) Enable merge queue * Add missing validation for the NATS stream provider (#9668) Add missing validation for the Nats stream provider * `ActivationDataActivatorProvider`: run grain constructor on grain scheduler (#9726) * ActivationDataActivatorProvider: always run grain constructor on ActivationTaskScheduler * ActivationDataActivatorProvider: always run grain constructor on ActivationTaskScheduler * Modifying Endpoint to use Pascale Casing as EndPoint for consistency (#9671) Co-authored-by: Ramzi Mourtada <[email protected]> * treat retirement tracker as a first-class (internal) machine --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Reuben Bond <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: Egil Hansen <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Bk <[email protected]> Co-authored-by: Da-Teach <[email protected]> Co-authored-by: Jerremy Koot <[email protected]> Co-authored-by: Gutemberg Ribeiro <[email protected]> Co-authored-by: Burak Büyükatlı <[email protected]> Co-authored-by: Ramzi Mourtada <[email protected]> Co-authored-by: Ramzi Mourtada <[email protected]>
Environment
Background
https://github.com/bknote71/OrleansTxInfoForkRaceConditionTest/blob/6fce8178d7f646d0ffcf06b49c5003b31bf41794/Client/Program.cs#L32
Cause:
Task.Run/Parallel.ForEachAsyncflows ExecutionContext includingAsyncLocal<TransactionInfo>in TransactionContext.orleans/src/Orleans.Transactions/TransactionContext.cs
Line 7 in daeddff
Fork()calls executePendingCalls++without synchronization → race condition.orleans/src/Orleans.Transactions/DistributedTM/TransactionInfo.cs
Line 73 in daeddff
How
Make PendingCalls atomic to match joined’s thread safety.
Microsoft Reviewers: Open in CodeFlow