Recently, during a client’s interaction via Skype, they informed me about an error they encountered while trying to set up mirroring between two SQL Server instances. The error message they received was:
2017-03-20 14:44:32.49 spid52 Starting up database 'PROD'. 2017-03-20 14:44:32.51 spid52 The database 'PROD' is marked RESTORING and is in a state that does not allow recovery to be run. 2017-03-20 14:46:13.53 Logon Database Mirroring login attempt by user 'ASIA\SQL_SERVICE.' failed with error: 'Connection handshake failed. Could not send a handshake message because the connection was closed by peer. State 26.' [CLIENT: 171.24.184.12]
Upon further investigation, we also found the following messages on the primary server:
2017-03-20 14:45:07.05 spid30s Error: 1443, Severity: 16, State: 2. 2017-03-20 14:45:07.05 spid30s Database mirroring has been terminated for database 'PROD'. This is an informational message only. No user action is required. 2017-03-20 14:45:50.01 spid47s Error: 1474, Severity: 16, State: 1. 2017-03-20 14:45:50.01 spid47s Database mirroring connection error 4 'An error occurred while receiving data: '10054(An existing connection was forcibly closed by the remote host.)'.' for 'TCP://171.24.184.13:5022'.
After analyzing the issue, we discovered that the error was caused by authentication issues of the service account from the domain controller. The networking team informed us that the ports were blocked in Active Directory, which resulted in the error.
To resolve this issue, the networking team unblocked the necessary ports in Active Directory. Unfortunately, we didn’t receive detailed information about the specific ports that were blocked and how they were unblocked. However, the networking team was able to easily identify and resolve the issue.
If you have encountered a similar error or would like to share your experience with troubleshooting SQL Server mirroring errors, please feel free to share your insights in the comments section below.