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

Fixes reader on closed connection problem #3335

Merged
merged 2 commits into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ internal static bool IsRetriable(this Exception e)
|| HasInternalSqlErrorPattern(str)
|| HasDatabaseAvailabilityPattern(str)
|| HasDatabaseOverloadPattern(str)
|| HasDeadlockErrorPattern(str)
|| HasReaderOnClosedConnectionPattern(str);
|| HasDeadlockErrorPattern(str);
}

internal static bool IsExecutionTimeout(this Exception e)
Expand Down Expand Up @@ -104,11 +103,5 @@ private static bool HasDatabaseOverloadPattern(string str)

////The request limit for the database is 200 and has been reached.
}

// TODO: This is temporary until transactions are removed from CSharp code, and we start using correct retry logic on merge.
private static bool HasReaderOnClosedConnectionPattern(string str)
{
return str.Contains("BeginExecuteReader requires an open and available Connection", StringComparison.OrdinalIgnoreCase) && str.Contains("current state is closed", StringComparison.OrdinalIgnoreCase);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ public async Task<IReadOnlyList<ResourceWrapper>> GetAsync(IReadOnlyList<Resourc
}

using var conn = await _sqlConnectionWrapperFactory.ObtainSqlConnectionWrapperAsync(cancellationToken, false);
using var cmd = conn.CreateRetrySqlCommand();
using var cmd = conn.CreateNonRetrySqlCommand(); // do not use incorrect retry logic
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "dbo.GetResources";
var tvpRows = keys.Select(_ => new ResourceKeyListRow(_model.GetResourceTypeId(_.ResourceType), _.Id, _.VersionId == null ? null : int.TryParse(_.VersionId, out var version) ? version : int.MinValue));
Expand Down