Database mirroring connection error 4

Between 2 sql server 2008 std sp1 servers mirroring is established using names in host files.
  • Remove From My Forums
  • Question

  • Between 2 sql server 2008 std sp1 servers mirroring is established using names in host files.

    This morning on the mirror we received

    Database mirroring connection error 4 ‘An error occurred while receiving data: ’64(The specified network name is no longer available.)’.’

    On the prinicipal we recieved

    The mirroring connection to «TCP://mirror_server_name_defrined in host file :7022» has timed out for database «database name» after 10 seconds without a response. Check the service and network connections.

    1 second later we receive:

    Database mirroring is active with database «database name» as the principal copy.

    So I have increased the timouts.  What I am trying to understand is what really happened. Since the names are set in host file my next thought is loss of network connectivity for > 10 seconds?  The mirroring is on private VLAN that goes across
    switch.

    • Edited by

      Tuesday, March 1, 2011 5:53 AM
      Formating

Answers

  • Enlist the help of your network engineers. I usually start by running a bunch of network-related commands like PATHPING and TRACERT to see where the potential network issue is


    Edwin Sarmiento SQL Server MVP
    Blog |
    Twitter | LinkedIn

    • Marked as answer by
      Alex Feng (SQL)
      Sunday, March 13, 2011 7:21 AM

  • It seems your principal unable to connect to mirrorring this could resources contension or network connection problem.

    Mirror will send hearbeat segnals to principal to check wether mirror is active default every second.  If their is no response from principal for 10 continuous segnals then mirror raise error saying that pricipal is not
    accessable also — vise versa with principal.

    It might be worth start profilers and see for any resources contension or connectivity issues

    • Marked as answer by
      Alex Feng (SQL)
      Sunday, March 13, 2011 7:21 AM

RRS feed

  • Remove From My Forums
  • Question

  • Database mirroring connection error 4 ‘An error occurred while receiving data: ‘10054(An existing connection was forcibly closed by the remote host.)’.’

    Witch setting inSQL reports this error, how to troubleshoot this?

    I already try to scan traffic between two hosts but everything is ok.

    I moment of error mirror i up and all tcp traffic is ok.

All replies

  •  

    Hi
    Tomislav Bartolic,

    Which version of SQL Server did you use? If it is SQL server 2016, this problem can be caused by that
    the database has had no activity for 90 seconds. You can refer to this support article:
    https://support.microsoft.com/en-us/help/3210699/fix-error-messages-are-logged-if-database-mirroring-is-configured-by-t

    Could you please share more error message to us for analysis, you can get related error message from Windows Event Viewer and
    C:Program FilesMicrosoft SQL ServerMSSQL**_[instance_name]MSSQLLog.

    In general, this problem can occur in the following scenarios if it is not a network problem:

    • We need to grant permission to all remote SQL instance connecting users to current
      instance DB Mirror End point
      , please check it by operating the following command:

    SELECT
    e.name
    as mirror_endpoint_name,
    s.name
    AS login_name

    ,
    p.permission_name,
    p.state_desc
    as permission_state,
    e.state_desc endpoint_state

    FROM
    sys.server_permissions p

    INNER JOIN
    sys.endpoints e
    ON p.major_id
    = e.endpoint_id

    INNER JOIN
    sys.server_principals s
    ON p.grantee_principal_id
    = s.principal_id

    WHERE
    p.class_desc
    = ‘ENDPOINT’
    AND e.type_desc
    = ‘DATABASE_MIRRORING’

    • Is it a cross domain environment? If it is, this problem can be caused by the
      certificate.

    Best Regards,

    Teige


    MSDN Community Support
    Please remember to click «Mark as Answer» the responses that resolved your issue, and to click «Unmark as Answer» if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to
    MSDN Support, feel free to contact MSDNFSF@microsoft.com.

I was trying to set up database mirroring in my freshly created Azure Virtual Machines and encountered an error. The error was talking about the connectivity problem, but it was something else. Let us learn about how to fix the database mirroring connection error 4.

Environment

  • SRV_P -Principal- Microsoft SQL Server 2014 – 12.0.4422.0 (X64)
  • SRV_M-Mirror- Microsoft SQL Server 2014 – 12.0.4422.0 (X64)
  • SRV_W-witness- SQL SERVER 2008 R2

SYMPTOMS

As soon as I configure database mirroring and click on “Start Mirroring”, I was getting below error.

Alter failed for Database ‘SQLAUTHORITY’. (Microsoft.SqlServer.Smo)
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)

The ALTER DATABASE command could not be sent to the remote server instance ‘TCP://SRV_W.SQLAUTHORITY.net:5022’.
The database mirroring configuration was not changed. Verify that the server is connected, and try again.
(Microsoft SQL Server, Error: 1456)

I looked around in ERRORLOG files to see if there is anything interesting.

PRINCIPAL SERVER

2016-12-26 01:23:16.710 spid43s Database mirroring connection error 4 ‘An error occurred while receiving data: ’24
(The program issued a command but the command length is incorrect.)’.’ for ‘TCP://SRV_W.sqlauthority.net:5022’.

2016-12-26 01:23:36.490 spid75 Error: 1456, Severity: 16, State: 3.

2016-12-26 01:23:36.490 spid75 The ALTER DATABASE command could not be sent to the remote server instance ‘TCP://SRV_W.sqlauthority.net:5022’. The database mirroring configuration was not changed. Verify that the server is connected, and try again.

2016-12-26 01:23:36.750 spid41s Database mirroring is active with database ‘SQLAUTH’ as the principal copy.
This is an informational message only. No user action is required.

MIRROR

2016-01-01 22:28:14.370 Logon Database Mirroring login attempt by user ‘SQLAUTHORITYSRV_P$.’ failed with error: 
‘Connection handshake failed. The login ‘SQLAUTHORITYSRV_P$’ does not have CONNECT permission on the endpoint. State 84.’.
[CLIENT: 10.0.40.34]

WORKAROUND/SOLUTION

I realized that this is a typical issue where service account is set to LocalSystem. Due to this mirroring, would use the machine name (having $ symbols at the end) to communicate. There are two workarounds for this.

  1. Change the Service account to domain account

    Read more here: SQL SERVER – Best Practices About SQL Server Service Account and Password Management

  1. If you don’t want to use domain account, then we need to create machine account as login and provide CONNECT permission to endpoint (as mentioned in error message)

On principal

use [master]
GO
CREATE LOGIN [SQLAUTHORITYSRV_M$] FROM WINDOWS
GO
GRANT CONNECT ON ENDPOINT::[Mirroring] TO [SQLAUTHORITYSRV_M$]
GO
use [master]
GO
CREATE LOGIN [SQLAUTHORITYSRV_W$] FROM WINDOWS
GO
GRANT CONNECT ON ENDPOINT::[Mirroring] TO [SQLAUTHORITYSRV_W$]

Notice that we are giving permission to machine account of mirror and witness. Same set of command to be run on Mirror and Witness as well with other two machines account.

On Mirror = SQLAUTHORITYSRV_W$ and SQLAUTHORITYSRV_P$
On Witness = SQLAUTHORITYSRV_P$ and SQLAUTHORITYSRV_M$

Same issue can happen in AlwaysOn availability group as well if account is set to LocalSystem.

Have you encountered such errors? What was the solution?

Reference: Pinal Dave (https://blog.sqlauthority.com)

Tags:

SQL Server

Pinal Dave

Written by Pinal Dave

Pinal Dave is a Microsoft Technology Evangelist (Database and BI). He has written over 1700 articles on the subject on his blog at http://blog.sqlauthority.com. He is a dynamic and proficient Principal Database Architect who specializes in SQL Server Performance Tuning and has 7+ years of hands-on experience. He holds a Masters of Science degree and a number of certifications, including MCTS, MCDBA and MCAD (.NET). He is also Regional Mentor for PASS Asia. Prior to joining Microsoft he was awarded Microsoft MVP award for three continuous years for his contribution in community.

SQL Server 2016 Developer SQL Server 2016 Enterprise SQL Server 2016 Enterprise Core More…Less

Symptoms

Assume that you use a Transact-SQL statement to set database mirroring in SQL Server 2016. After this is configured, you see continuous errors that resemble the following in the SQL Server error log:

<Principal>
date time spid47s Error: 1479, Severity: 16, State: 1.
date time spid47s The mirroring connection to «TCP://Node02.contoso.com:5022» has timed out for database «MirrorDB» after 10 seconds without a response. Check the service and network connections.
date time spid47s Database mirroring is inactive for database ‘MirrorDB‘. This is an informational message only. No user action is required.
date time spid47s Database mirroring is active with database ‘MirrorDB‘ as the principal copy. This is an informational message only. No user action is required.
</Principal>
<MIRROR>
date time spid53s Error: 1474, Severity: 16, State: 1.
date time spid53s Database mirroring connection error 4 ‘An error occurred while receiving data: ‘10054(An existing connection was forcibly closed by the remote host.)’.’ for ‘TCP://Node01.contoso.com:5022’.
date time spid44s Database mirroring is inactive for database ‘MirrorDB‘. This is an informational message only. No user action is required.
date time spid44s Database mirroring is active with database ‘MirrorDB‘ as the mirror copy. This is an informational message only. No user action is required.
</MIRROR>

Cause

This error may be logged when the network is functioning correctly but the database has had no activity for 90 seconds. SQL Server checks and then closes the database mirroring connection when there is no database activity for 90 seconds. When database activities resume, a connection is reestablished, and database mirroring starts working again.

Resolution

The update that fixes this issue is included in the following cumulative updates:

  • Cumulative Update 1 for SQL Server 2016 Service Pack 1

  • Cumulative Update 4 for SQL Server 2016

About SQL Server 2016 builds

Each new build for SQL Server 2016 contains all the hotfixes and all the security fixes that were included with the previous build. We recommend that you install the latest build for SQL Server 2016.

Status

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the «Applies to» section.

References

Learn about the terminologythat Microsoft uses to describe software updates.

Need more help?

A SQL Server mirroring of the company failed over (active/standby switchover). Check the reason for the main/standby switchover of SQL Server mirroring. The following error was found in the error log:

clip_image001

Date        2019/8/31 14:09:17
 
Log     SQL Server (Archive #4 - 2019/9/1 0:00:00)
 
 
 
Source      spid35s
 
 
 
Message
 
Database mirroring connection error 4 'An error occurred while receiving data: '10054(An existing connection was forcibly closed by the remote host.)'.' for 'TCP://xxxxx:7022'. .

Check the system log of the witness server and find the following error message, which indicates that the witness server cannot get a response from the database after more than 10 seconds. Please check the service or network connections. (Check the service and network connections.)

clip_image002

At this point in the analysis, I can only guess that the SQL Server service abnormality or network abnormality caused the witness server to be unable to access the main server for more than 10 seconds, which caused the main/standby switch. When I asked the system administrator to assist in the analysis, the system administrator confirmed Saturday 14 Click on the main server that is using Veeam Backup & Replication to back up the mirror during that time period (he is testing the use of Veeam Backup & Replication to back up the VmWare virtual machine), but will this Veeam Backup & Replication backup cause network interruption? So, on Monday, we found a time to test whether Veeam Backup & Replication backup really caused network interruption. During the test, it was found that it really caused network interruption (it is not clear whether it is a setting problem or other mechanism reasons. ), the test process has indeed verified that the Veeam Backup & Replication backup caused the network interruption, which caused the master-slave switch of the mirroring, hereby record this case!

Read More:

Hello,

So I was sleeping for this event, but when I came in this morning there were several emails alerts saying the mirror lost the witness, the mirror lost the principal, and the principal lost the witness.  Now I understand mirroring from a text book sense in that I have read about it.  Our more season DBA was paged a bunch last night, and he told me that a bunch of databases where in a disconnected state.  To get them back to a synchronized state he restarted the instance service.

I was wondering if there was a best practice for getting it backup and running?  Other times it has failed we’ve had to disable the mirroring and reinitialize it to get it working.  In some scenarios we’ve had to disable mirroring, backup the principal and restore it to the mirror before it would allow us to continue.

What caused this failure I still don’t know but the windows log is ripe with errors relating to SQL Server.

EVENT 1474:

Database mirroring connection error 4 ‘An error occurred while receiving data: ‘10054(An existing connection was forcibly closed by the remote host.)’.’

Database mirroring connection error 4 ‘An error occurred while receiving data: ’64(The specified network name is no longer available.)’.’

There are also a bunch of SQL logon errors saying SQL Server is not ready to accept new client connections and that the client was unable to reuse a session with SPID etc…  Can these be related?

I have only been at the company 9 days but they want me to help figure out why fixing mirroring is such a routine task.

This information may all be to vague, but figure i’d try.


  • Hi,

    I’m trying to set up database mirroring using the database mirroring wizard in SQL Server 2008 R2 RTM x64 developer edition on Windows Server 2008 R2 EE x64 SP.

    Primary Server: SRV1

    Instance:SRV1/ins1

    Mirror Server:SRV2

    Instance:SRV2ins1

    I have selected all default configuration in the wizard to set up mirroring for AdventureWorks database .

    But getting the below error:

    I’m able to telnet the port 5022 from both the servers SRV1 & SRV2.

    I did turn OFF the Windows firewall too.

    Do we need to do anything with MSDTC configuration?

    What else do I need to verify to resolve the issue?

    Thanks

  • Perry Whittle

    SSC Guru

    Points: 233806

    Is ABC.com your actual domain name?

    Database mirroring error


    The server network address «TCP://SRV1.ABC.COM:5022» can not be reached or does not exist. Check the network address name and that the ports for the local and remote endpoints are operational. (Microsoft SQL Server, Error: 1418)

    ————————————————————————————————————

    «Ya can’t make an omelette without breaking just a few eggs» 😉

  • pshaship

    SSCertifiable

    Points: 6125

    No. ABC.COM is NOT the actual domain. I have replaced my actual domain name with ABC while posting in the forum.

  • seth delconte

    SSCertifiable

    Points: 6388

    Here are some good related fixes… are you getting that error for your Principal server (I assume so, since I believe 5022 is the default port…).

    http://blog.sqlauthority.com/2010/01/11/the-server-network-address-tcpsqlserver5023-can-not-be-reached-or-does-not-exist-check-the-network-address-name-and-that-the-ports-for-the-local-and-remote-endpoints-are-operational-microso/[/url]

    http://blog.sqlauthority.com/2007/04/22/sql-server-fix-error-1418-microsoft-sql-server-the-server-network-address-can-not-be-reached-or-does-not-exist-check-the-network-address-name-and-reissue-the-command/[/url]

  • pshaship

    SSCertifiable

    Points: 6125

    Thanks for the links.

    Below are the error messages from the errorlog

    On Principal server’s error log:

    Database mirroring connection error 4 ‘An error occurred while receiving data: ‘10054(An existing connection was forcibly closed by the remote host.)’.’ for ‘TCP://SRV2.ABC.COM:5022’.

    On Mirror Server’s errorlog

    Database Mirroring login attempt by user ‘ABCmssqlsrv.’ failed with error: ‘Connection handshake failed. The login ‘ABCmssqlsrv’ does not have CONNECT permission on the endpoint. State 84.’. [CLIENT: 10.10.10.13]

    I tried to grant the connect permission to ABCmssqlsrv but it’s complaining that the login DOES NOT exist.

    GRANT CONNECT ON ENDPOINT::Mirroring TO [ABCmssqlsrv]

    Msg 15151, Level 16, State 1, Line 1

    Cannot find the login ‘ABCmssqlsrv’, because it does not exist or you do not have permission.

    Please advice..

  • seth delconte

    SSCertifiable

    Points: 6388

    Have you restored the last transaction log backup on the mirror instance with NO RECOVERY?

    http://www.sqlservercentral.com/Forums/Topic683162-146-1.aspx#bm684411

    Also, check and see what login accounts your SQL services are using — apparently you need certificates if you are using Local Service Accounts:

    http://social.msdn.microsoft.com/Forums/en-US/sqldatabasemirroring/thread/73fb15c0-9270-4cbf-a74e-544639e792da/[/url]

  • Perry Whittle

    SSC Guru

    Points: 233806

    pshaship (7/12/2011)


    Thanks for the links.

    Below are the error messages from the errorlog

    On Principal server’s error log:

    Database mirroring connection error 4 ‘An error occurred while receiving data: ‘10054(An existing connection was forcibly closed by the remote host.)’.’ for ‘TCP://SRV2.ABC.COM:5022’.

    On Mirror Server’s errorlog

    Database Mirroring login attempt by user ‘ABCmssqlsrv.’ failed with error: ‘Connection handshake failed. The login ‘ABCmssqlsrv’ does not have CONNECT permission on the endpoint. State 84.’. [CLIENT: 10.10.10.13]

    I tried to grant the connect permission to ABCmssqlsrv but it’s complaining that the login DOES NOT exist.

    GRANT CONNECT ON ENDPOINT::Mirroring TO [ABCmssqlsrv]

    Msg 15151, Level 16, State 1, Line 1

    Cannot find the login ‘ABCmssqlsrv’, because it does not exist or you do not have permission.

    Please advice..

    add the login to the mirror instance and grant connect permissions to the endpoint and re try

    ————————————————————————————————————

    «Ya can’t make an omelette without breaking just a few eggs» 😉

  • pshaship

    SSCertifiable

    Points: 6125

    Issue resolved:-)

    Reason for the issue:

    The SQL Server service account abcmssqlsrv did not exit in logins on both Principal & Mirror

    Solution:

    Add the service account in logins on both the servers and grant the connect permission as below;

    GRANT CONNECT ON ENDPOINT::Mirroring TO [abcmssqlsrv]

    Hope this helps someone!!

  • Perry Whittle

    SSC Guru

    Points: 233806

    geenrally you dont want to use the sql server service account as the security principal for your endpoints. Create a base domain user, grant login to sql server and grant connect permissions to the end point

    ————————————————————————————————————

    «Ya can’t make an omelette without breaking just a few eggs» 😉

  • Ignacio A. Salom Rangel

    SSC-Insane

    Points: 20443

    pshaship (7/12/2011)


    Issue resolved:-)

    Reason for the issue:

    The SQL Server service account abcmssqlsrv did not exit in logins on both Principal & Mirror

    Solution:

    Add the service account in logins on both the servers and grant the connect permission as below;

    GRANT CONNECT ON ENDPOINT::Mirroring TO [abcmssqlsrv]

    Hope this helps someone!!

    Thanks for sharing!

Viewing 10 posts — 1 through 9 (of 9 total)

Понравилась статья? Поделить с друзьями:

Читайте также:

  • Dayz memory error
  • Dayz launcher ошибка 103
  • Database error value received
  • Dayz launcher sa steam error
  • Database error unable to connect to the database could not connect to mysql перевод

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии