Sql-server – TFS Installation Fails over to mirroring secondary despite not having a Fail-over partner specified

failovermirroringsql-server-2016

We have TFS Version 15.105.27412.0 installed on a server (Server A) and have it configured to point at our database server (Server B).

We have the two TFS databases (tfs_defaultcollection and tfs_configuration) on ServerB and they are mirrored with ServerC, however the connection string in the configuration manager for TFS is not "mirroring aware" – see screenshot below from TFS Administration Console

image

Furthermore, if I interrogate the TFS configuration database as follows

SELECT * FROM Tfs_configuration.dbo.tbl_Database

This confirms the connection strings for both databases do not have failover partners specified.

enter image description here

We had a planned failover this morning from ServerB to ServerC which included both of the TFS databases and much to everyone's surprise, TFS continued to function with the databases failover and running on ServerC.

I stopped the SQL Server service on ServerB and ran an ExtendedEvents session on ServerC (looking for queries that accessed the TFS databases) and can confirm that the TFS application was indeed querying ServerC.

How did this happen? The TFS installation has no idea that ServerC exists, is something happening at the SQL Server level?

Best Answer

Specifying Failover Partner in the connection string is only for an initial connection. After connecting the client is notified of the failover partner, and will use that for reconnecting in case of a failover.

[After connecting to the principal] the data access provider downloads the server instance name of the current mirror server. This name is stored in the cache as the failover partner name, overwriting the client-supplied failover partner name, if any.

Connect Clients to a Database Mirroring Session

So even applications not specifically configured for database mirroring will discover the failover partner at startup.

our TFS installation has no failover partner specified

So on reboot or cold start TFS will fail to connect if server specified in its connection string is not available and hosting the principal database. But if a failover occurs after TFS has succesfully connected to the principal it will know to reconnect to the failover partner.