Sql-server – Replication throw an error after failover mirror partner is down in SQL Server

failovermirroringsql servertransactional-replication

Received an error mentioned below after failover when mirror partner is down.

Error :

to fail over to a database which is not configured for database
mirroring. code: 22037, text: 'Invalid connection string
attributeCannot open database "DBName" requested by the login. The login
failed.Login failed for user 'domain\user'.The connection attempted to
fail over to a database which is not configured for database
mirroring.'.

Scenario :

  1. X is a Principal server and Y is a mirror partner of X
  2. X is a publisher too, Z is a distributor server
  3. Z is added as distributor in X and Y Server. X and Y added as publisher in Z server too
  4. Configured Y as a "PublisherFailoverPartner" in replication log reader agent profile setting
  5. Did failover of X
  6. Thereafter Y became a principal and X became mirror partner
  7. Break mirror from Y to X or X server is down and unavailable

After above steps performed, replication is started to throw an error. When mirror is ON the replication is working, otherwise it raising an error mentioned.

Can you please suggest me steps to resolve it?

Best Answer

This should work as it did for me:

Set the -failoverpartner using the mirror name in the sql agents for replication. Fail mirror over to secondary

Make sure replication continues to send commands to subscriber.

Remove mirroring so primary is no longer connected.

Go to distributor, add an alias (sql server alias)
The alias should be the old principal name pointing to the secondary server.

Replication will continue without errors, however jobs (and replication monitor) will show everything under the primary mirror server.