Error 'Could not open a connection to SQL Server' while upgrading database with codefluent pivot runner

0

We use the pivot runner to update our databases. Since a year we regularly receive error message below. The database server is available, and is hardly used by other processes. After restarting, the same message usually reappears several times, but not always with the same action. As soon as we have managed to update the first database, updating the other (40+) databases also runs smoothly. Any idea what could be the cause of this?

System.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The ser
ver was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: N
amed Pipes Provider, error: 40 - Could not open a connection to SQL Server) ---> System.ComponentModel.Win32Exception (0x80004005): Access is denied
   at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential
, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, Session
Data reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling, SqlAuthenticationProviderManager sqlAuthProviderMa
nager)
   at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbC
onnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOpti
ons userOptions)
   at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOpti
ons, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskComple
tionSource`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 CodeFluent.Runtime.Database.Management.Database.GetSchema(String collectionName, String[] restrictionValues)
   at CodeFluent.Runtime.Database.Management.SqlServer.Key.Construct(DataRow row)
   at CodeFluent.Runtime.Database.Management.Key..ctor(Table table, DataRow row)
   at CodeFluent.Runtime.Database.Management.SqlServer.Table.NewKey(DataRow row)
   at CodeFluent.Runtime.Database.Management.SqlServer.Table.GetKeys()
   at CodeFluent.Runtime.Database.Management.Table.get_Keys()
   at CodeFluent.Runtime.Database.Management.Database.ResolveReferencingKeys(Boolean refresh)
   at CodeFluent.Runtime.Database.Management.Table.get_ReferencingForeignKeys()
   at CodeFluent.Runtime.Database.Management.SqlServer.PivotRunner.<GetConstraintReferencingKeys>d__6.MoveNext()
   at CodeFluent.Runtime.Database.Management.SqlServer.PivotRunner.DropConstraint(String tableSchema, String tableName, String constraintName, DistinctDictio
nary`1 constraints)
   at CodeFluent.Runtime.Database.Management.SqlServer.PivotRunner.DropConstraint(String tableSchema, String tableName, String constraintName)
   at CodeFluent.Runtime.Database.Management.SqlServer.PivotRunner.UpdateColumn(PivotRunnerColumn column, Column existingColumn)
   at CodeFluent.Runtime.Database.Management.SqlServer.PivotRunner.UpdateTable(PivotRunnerTable table, Table existingTable)
   at CodeFluent.Runtime.Database.Management.SqlServer.PivotRunner.Run()
sql-server
codefluent
asked on Stack Overflow Aug 11, 2020 by Ellen

1 Answer

0

Difficult to say without the model and the databases. However if it used to work (so assuming the connection string is correct, SQL protocol still enabled, same machine and no change of permissions on the DB for the user) and if the error is not always on the same update step, it may be related to a previous timeout on some DB action, or a previous action not yet finished : for instance a previous index added not yet fully populated or reindexed. It can happen on growing database. Another reason may be a job task running, like a backup. Before launching the PivotRunner tool, ensure with Management Studio there is no other running/blocking transactions in progress or not too many opened connections to this DB from previous run/tests (sp_who) My 2 cents.

answered on Stack Overflow Aug 31, 2020 by MCR

User contributions licensed under CC BY-SA 3.0