microsoft / microsoft/durabletask-mssql

Add resiliency to SQL data reader read operations

Open
#151 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
105
Forks
36
PR merge metrics
No merged PRs in 30d

Description

I noticed the following failure in the CI:

[xUnit.net 00:00:06.69]     DurableTask.SqlServer.Tests.Integration.DataRetentionTests.InvalidTimerEventsAreDiscarded [FAIL]
  Failed DurableTask.SqlServer.Tests.Integration.DataRetentionTests.InvalidTimerEventsAreDiscarded [3 s]
  Error Message:
   Microsoft.Data.SqlClient.SqlException : Transaction (Process ID 92) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.
  Stack Trace:
     at Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   at Microsoft.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
   at Microsoft.Data.SqlClient.SqlDataReader.TryHasMoreRows(Boolean& moreRows)
   at Microsoft.Data.SqlClient.SqlDataReader.TryReadInternal(Boolean setTimeout, Boolean& more)
   at Microsoft.Data.SqlClient.SqlDataReader.Read()
   at DurableTask.SqlServer.SqlOrchestrationService.GetOrchestrationStateAsync(String instanceId, String executionId, CancellationToken cancellationToken) in /home/runner/work/durabletask-mssql/durabletask-mssql/src/DurableTask.SqlServer/SqlOrchestrationService.cs:line 607
   at DurableTask.SqlServer.Tests.Utils.TestInstance`1.WaitForStart(TimeSpan timeout) in /home/runner/work/durabletask-mssql/durabletask-mssql/test/DurableTask.SqlServer.Tests/Utils/TestInstance.cs:line [56](https://github.com/microsoft/durabletask-mssql/actions/runs/4107266240/jobs/7086524989#step:7:57)
   at DurableTask.SqlServer.Tests.Integration.DataRetentionTests.InvalidTimerEventsAreDiscarded() in /home/runner/work/durabletask-mssql/durabletask-mssql/test/DurableTask.SqlServer.Tests/Integration/DataRetentionTests.cs:line 218

We have transient failure handling for the ExecuteReaderAsync call, but not for any subsequent Read calls.

We should find a way to add transient failure handling to these individual Read operations as well to avoid letting failures unnecessarily propagate up to the caller.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/DurableTask.SqlServer/SqlOrchestrationService.cs, especially GetOrchestrationStateAsync around line 607, and inspect how ExecuteReaderAsync currently handles transient failures before subsequent Read calls. Run the failing InvalidTimerEventsAreDiscarded integration test in test/DurableTask.SqlServer.Tests/Integration/DataRetentionTests.cs; done means transient failures during reader reads no longer unnecessarily propagate to callers.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, sql
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.