with studio net management c# .net sql-server azure azure-sql-database

c# - studio - Error interno 6 del proveedor de datos de.Net Framework en SQL Azure



sql server azure connect (1)

Experimento regularmente el error anterior al crear conexiones a bases de datos Azure SQL. Implementé ReliableSqlConnection con la lógica de reintento para intentar evitar este problema, pero fue en vano. Lo que sigue es un rastro de pila de error de ejemplo:

System.InvalidOperationException Internal .Net Framework Data Provider error 6. System.InvalidOperationException: Internal .Net Framework Data Provider error 6. at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry) at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) at System.Data.SqlClient.SqlConnection.Open() at Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling.ReliableSqlConnection.<Open>b__1() at Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling.RetryPolicy.<>c__DisplayClass1.<ExecuteAction>b__0() at Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling.RetryPolicy.ExecuteAction[TResult](Func`1 func) at Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling.RetryPolicy.ExecuteAction(Action action) at Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling.ReliableSqlConnection.<Open>b__0() at Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling.RetryPolicy.<>c__DisplayClass1.<ExecuteAction>b__0() at Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling.RetryPolicy.ExecuteAction[TResult](Func`1 func) at Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling.RetryPolicy.ExecuteAction(Action action) at Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling.ReliableSqlConnection.Open(RetryPolicy retryPolicy)

Este problema ocurre al crear una nueva base de datos en un conjunto elástico. El texto del comando SQL se ejecuta en el siguiente método:

public void ExecuteCommandText(string commandText) { if (IsNullOrEmpty(commandText)) throw new ArgumentNullException(nameof(commandText)); List<string> commandSteps = SplitCommandText(commandText); using (var sqlConnection = CreateConnection()) { foreach (string commandStep in commandSteps) { using (SqlCommand command = sqlConnection.CreateCommand()) { command.CommandText = commandStep; command.CommandTimeout = _commandTimeout; command.ExecuteNonQuery(); command.Dispose(); } } } }

Dónde:

private ReliableSqlConnection CreateConnection() { if (IsNullOrEmpty(ConnectionString)) throw new InvalidOperationException("Connection string is not defined."); ReliableSqlConnection sqlConnection = new ReliableSqlConnection(ConnectionString, _retryPolicy, _retryPolicy); sqlConnection.Open(); return sqlConnection; }

Y:

var retryStrategy = new ExponentialBackoff(5, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(60), TimeSpan.FromSeconds(2)); _retryPolicy = new RetryPolicy<SqlDatabaseTransientErrorDetectionStrategy>(retryStrategy);

La cadena de conexión tiene el formato:

$"Server=tcp:{serverName},1433;Data Source={serverName};Persist Security Info=False;User ID=''{user}'';Password=''{password}'';MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=90;"

Además, he comprobado el uso de eDTU en mi grupo elástico:

Uso elástico de la piscina eDTU

El primer pico es crear 1 base de datos en el grupo, el segundo es para 2, el tercero es para 3 y el cuarto es para crear 4 bases de datos al mismo tiempo. El nivel de servicio de grupo elástico es Estándar 100.