Common Causes and Troubleshooting Solutions for SQL AG Data Synchronization Latency

Published Nov 14 2021 03:11 AM 1,617 Views
Microsoft

This article summarizes the common causes , solutions and troubleshooting mechanism for SQL Availability Group (AG) data synchronization latency between primary and secondary for both synchronous-commit and asynchronous-commit mode.

 

The latency commonly happens at log harden phase or log redo phase. And sometimes, both. If it happens at log harden phase, you will likely to see HADR_SYNC_COMMIT wait type in your primary that waiting for your synchronous-commit secondary replica's acknowledgement. Also, your primary is likely to encounter latency on committing transactions sent from application because of this wait.  If latency happens purely at log redo phase, you are likely to see a relatively low redo rate in your issued secondary replica with high value of redo queue.

 

The key point is to first narrow down the actual phase of workflow (attached at the bottom of this article as also mentioned in a few other blogs thanks to great work of @Simon Su )in data synchronization that induces the latency. 

 

For experienced DBA, if you have already narrowed down the latency to be caused by extensive HADR_SYNC_COMMIT wait type in your primary for your synchronous-commit secondary replica, you can refer to this article for resolving this bottleneck : https://techcommunity.microsoft.com/t5/sql-server/troubleshooting-high-hadr-sync-commit-wait-type-wi... 

 

If you wish to capture detailed traces to narrow down the bottleneck, except for performance monitor counters where you can check log send and redo efficiency, blocking chain and its block header on primary replica, SQL AG dedicated X-events in both primary and issued secondary are also required to see the data synchronization workflow latency. We have an automatic tool "AGLatency Report Tool" to help you analyze the AG X-event data thanks to the great work of @Simon Su . You can find this tool in this link with its user manual and the AG X-event script in this link 

 

Below are the common causes and its solution/troubleshooting mechanism for SQL AG Data Synchronization Latency:

 

  • Long-running active transactions in read-only secondary replica ---- > When there is a long-running transaction in readable secondary replica, there can be blocking for the local redo thread in secondary replica when accessing the same data.
  • High network latency / low network throughput  ----> When the network transmission between primary and the issued secondary is slow or instable, the log send rate will be slow and impact the amount of data being transmitted to secondary(refer doc https://docs.microsoft.com/en-us/previous-versions/sql/sql-server-2012/dn135335(v=sql.110)?redirecte...
  • Flow control induced high log send queue size and low log send rate ---- >  When your SQL AG's performance triggered flow control gate for specific SQL AG databases or at SQL AG replica level, there would be temporary termination and limitation of sending log data from primary to secondary. Flow control can be commonly caused by server overloading or slow network. We need to resolve the conditions in your environment that cause the flow control if we have constantly observed flow control gate being entered by your AG. You can check below performance monitor counters to see if your SQL AG Database or SQL AG replica has ever triggered flow control gate:

     

    AG Replica level

     

    Availability Replica : Flow Control Time ,

    Availability Replica : Flow Control/sec ,

     

    AG Database Level

    Database Replica: Database Flow Control Delay
    Database Replica: Database Flow Controls/Sec
     
     (For Flow Control Gate details as discussed below, please refer this link Monitor Performance for AlwaysOn Availability Groups | Microsoft Docs)
    AlwaysOn Availability Groups is designed with flow control gates on the primary replica to avoid excessive resource consumption, such as network and memory resources, on all availability replicas. These flow control gates do not affect t
    he synchronization health state of the availability replicas, but they can affect the overall performance of your availability databases, including RPO.

    After the logs have been captured on the primary replica, they are subject to two levels of flow controls, as shown in the table below.

    Level

    Number of Gates

    Number of messages

    Useful Metrics

    Transport

    1 per availabiltiy replica

    8192

    Extended event database_transport_flow_control_action

    Database

    1 per availability database

    11200 (x64)

     

    1600 (x86)

    DBMIRROR_SEND

     

    Extended event hadron_database_flow_control_action

    FLOW CONTROL GATES

    Once the message threshold of either gate is reached, log messages are no longer sent to a specific replica or for a specific database. These can be sent once acknowledgement messages are received for the sent messages to bring the number of sent messages below the threshold. In addition to the flow control gates, there is another factor that can prevent the log messages from being sent. The synchronization of replicas ensures that the messages are sent and applied in the order of the log sequence numbers (LSN). Before a log message is sent, its LSN also checked against the lowest acknowledged LSN number to make sure that it is less than one of thresholds (depending on the message type). If the gap between the two LSN numbers is larger than the threshold, the messages are not sent. Once the gap is below the threshold again, the messages are sent.

  • Blocked REDO thread  ---- When there are other issues or performance bottlenecks in secondary replica, the REDO thread can be blocked and cause latency of data synchronization. Refer document https://techcommunity.microsoft.com/t5/sql-server/alwayson-minimizing-blocking-of-redo-thread-when-r...
  • Shared REDO Target  -----  This issue only happens when you have multiple secondary replicas. When one secondary replica is very slow in finishing the redo process, it will limit the other secondary replicas in proceeding further on the maximum allowable LSN with the redo process. Trace flag 9559 can be used to mitigate the issue. (refer doc https://docs.microsoft.com/en-us/archive/blogs/alwaysonpro/recovery-on-secondary-lagging-shared-redo...)
  • Running out of parallel redo threads in secondary replica --- When secondary replica is running out of parallel redo threads, you can use TF3478 to allow maximal number of parallel redo thread to increase with total number of CPUs. By default, A SQL Server instance uses up to 100 threads for parallel redo for secondary replicas. Each database uses up to one-half of the total number of CPU cores, but not more than 16 threads per database. If the total number of required threads for a single instance exceeds 100, SQL Server uses a single redo thread for every remaining database.
  • Disk or I/O subsystem latency -- > when the disk or I/O subsystem in the secondary replica has critical bottleneck, the redo rate will be impacted and quite small in secondary replica. We are less likely to see it in your secondary before it hit on primary if your secondary replica is not readable and has comparable hardware for SQL database files' storage as that in primary and dedicated for this SQL AG's usage. However, if your secondary replica has high volume of read-only workload, it can bring extra IO overhead to your IO subsystem.  Frequent database backup and VM snapshot can be another potential cause of extra I/O overhead. 

 

EstherXinMSFT_1-1636888132744.png

 

%3CLINGO-SUB%20id%3D%22lingo-sub-2963083%22%20slang%3D%22en-US%22%3ECommon%20Causes%20and%20Troubleshooting%20Solutions%20for%20SQL%20AG%20Data%20Synchronization%20Latency%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2963083%22%20slang%3D%22en-US%22%3E%3CP%3EThis%20article%20summarizes%20the%20common%20causes%20%2C%20solutions%20and%20troubleshooting%20mechanism%20for%20SQL%20Availability%20Group%20(AG)%20data%20synchronization%20latency%20between%20primary%20and%20secondary%20for%20both%20synchronous-commit%20and%20asynchronous-commit%20mode.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20latency%20commonly%20happens%20at%20log%20harden%20phase%20or%20log%20redo%20phase.%20And%20sometimes%2C%20both.%20If%20it%20happens%20at%20log%20harden%20phase%2C%20you%20will%20likely%20to%20see%20HADR_SYNC_COMMIT%20wait%20type%20in%20your%20primary%20that%20waiting%20for%20your%20synchronous-commit%20secondary%20replica's%20acknowledgement.%20Also%2C%20your%20primary%20is%20likely%20to%20encounter%20latency%20on%20committing%20transactions%20sent%20from%20application%20because%20of%20this%20wait.%26nbsp%3B%20If%20latency%20happens%20purely%20at%20log%20redo%20phase%2C%20you%20are%20likely%20to%20see%20a%20relatively%20low%20redo%20rate%20in%20your%20issued%20secondary%20replica%20with%20high%20value%20of%20redo%20queue.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20key%20point%20is%20to%20first%20narrow%20down%20the%20actual%20phase%20of%20workflow%20(attached%20at%20the%20bottom%20of%20this%20article%20as%20also%20mentioned%20in%20a%20few%20other%20blogs%20thanks%20to%20great%20work%20of%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F231529%22%20target%3D%22_blank%22%3E%40Simon%20Su%3C%2FA%3E%26nbsp%3B)in%20data%20synchronization%20that%20induces%20the%20latency.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFor%20experienced%20DBA%2C%20if%20you%20have%20already%20narrowed%20down%20the%20latency%20to%20be%20caused%20by%20extensive%20%3CSTRONG%3EHADR_SYNC_COMMIT%3C%2FSTRONG%3E%20wait%20type%20in%20your%20primary%20for%20your%20synchronous-commit%20secondary%20replica%2C%20you%20can%20refer%20to%20this%20article%20for%20resolving%20this%20bottleneck%20%3A%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fsql-server%2Ftroubleshooting-high-hadr-sync-commit-wait-type-with-always-on%2Fba-p%2F385369%22%20target%3D%22_blank%22%3Ehttps%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fsql-server%2Ftroubleshooting-high-hadr-sync-commit-wait-type-with-always-on%2Fba-p%2F385369%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20wish%20to%20capture%20detailed%20traces%20to%20narrow%20down%20the%20bottleneck%2C%20except%20for%20performance%20monitor%20counters%20where%20you%20can%20check%20log%20send%20and%20redo%20efficiency%2C%20blocking%20chain%20and%20its%20block%20header%20on%20primary%20replica%2C%20SQL%20AG%20dedicated%20X-events%20in%20both%20primary%20and%20issued%20secondary%20are%20also%20required%20to%20see%20the%20data%20synchronization%20workflow%20latency.%20We%20have%20an%20automatic%20tool%20%22AGLatency%20Report%20Tool%22%20to%20help%20you%20analyze%20the%20AG%20X-event%20data%20thanks%20to%20the%20great%20work%20of%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F231529%22%20target%3D%22_blank%22%3E%40Simon%20Su%3C%2FA%3E%26nbsp%3B.%20You%20can%20find%20this%20tool%20in%20this%20link%20with%20its%20user%20manual%20and%20the%20AG%20X-event%20script%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fsql-server-support%2Faglatency-report-tool-v2-2-introduction%2Fba-p%2F319186%22%20target%3D%22_blank%22%3E%20in%20this%20link%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EBelow%20are%20the%20common%20causes%20and%20its%20solution%2Ftroubleshooting%20mechanism%20for%20SQL%20AG%20Data%20Synchronization%20Latency%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSTRONG%3ELong-running%20active%20transactions%3C%2FSTRONG%3E%26nbsp%3Bin%20read-only%20secondary%20replica%20----%20%26gt%3B%20When%20there%20is%20a%20long-running%20transaction%20in%20%3CSTRONG%3Ereadable%20secondary%20replica%3C%2FSTRONG%3E%2C%20there%20can%20be%20%3CSTRONG%3Eblocking%20for%20the%20local%20redo%20thread%3C%2FSTRONG%3E%20in%20secondary%20replica%20when%20accessing%20the%20same%20data.%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EHigh%20network%20latency%20%2F%20low%20network%20throughput%3C%2FSTRONG%3E%26nbsp%3B%20----%26gt%3B%20When%20the%20network%20transmission%20between%20primary%20and%20the%20issued%20secondary%20is%20slow%20or%20instable%2C%20the%20log%20send%20rate%20will%20be%20slow%20and%20impact%20the%20amount%20of%20data%20being%20transmitted%20to%20secondary(refer%20doc%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fprevious-versions%2Fsql%2Fsql-server-2012%2Fdn135335(v%3Dsql.110)%3Fredirectedfrom%3DMSDN%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fprevious-versions%2Fsql%2Fsql-server-2012%2Fdn135335(v%3Dsql.110)%3Fredirectedfrom%3DMSDN%3C%2FA%3E)%26nbsp%3B%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EFlow%20control%20induced%20high%20log%20send%20queue%20size%20and%20low%20log%20send%20rate%20%3C%2FSTRONG%3E----%20%26gt%3B%3CSTRONG%3E%26nbsp%3B%20%3C%2FSTRONG%3EWhen%20your%20SQL%20AG's%20performance%20triggered%20flow%20control%20gate%20for%20specific%20SQL%20AG%20databases%20or%20at%20SQL%20AG%20replica%20level%2C%20there%20would%20be%20temporary%20termination%20and%20limitation%20of%20sending%20log%20data%20from%20primary%20to%20secondary.%20Flow%20control%20can%20be%20commonly%20caused%20by%20server%20overloading%20or%20slow%20network.%20We%20need%20to%20resolve%20the%20conditions%20in%20your%20environment%20that%20cause%20the%20flow%20control%20if%20we%20have%20constantly%20observed%20flow%20control%20gate%20being%20entered%20by%20your%20AG.%20You%20can%20check%20below%20performance%20monitor%20counters%20to%20see%20if%20your%20SQL%20AG%20Database%20or%20SQL%20AG%20replica%20has%20ever%20triggered%20flow%20control%20gate%3A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAG%20Replica%20level%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAvailability%20Replica%20%3A%20Flow%20Control%20Time%20%2C%3C%2FP%3E%0A%3CP%3EAvailability%20Replica%20%3A%20Flow%20Control%2Fsec%20%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAG%20Database%20Level%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%3CSPAN%20style%3D%22background%3A%20white%3B%22%3EDatabase%20Replica%3A%20Database%20Flow%20Control%20Delay%3CBR%20%2F%3EDatabase%20Replica%3A%20Database%20Flow%20Controls%2FSec%3CBR%20%2F%3E%26nbsp%3B%3CBR%20%2F%3E%26nbsp%3B(For%20Flow%20Control%20Gate%20details%20as%20discussed%20below%2C%20please%20refer%20this%20link%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fprevious-versions%2Fsql%2Fsql-server-2012%2Fdn135338(v%3Dsql.110)%3Fredirectedfrom%3DMSDN%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EMonitor%20Performance%20for%20AlwaysOn%20Availability%20Groups%20%7C%20Microsoft%20Docs%3C%2FA%3E)%3CBR%20%2F%3EAlwaysOn%20Availability%20Groups%20is%20designed%20with%20flow%20control%20gates%20on%20the%20primary%20replica%20to%20avoid%20excessive%20resource%20consumption%2C%20such%20as%20network%20and%20memory%20resources%2C%20on%20all%20availability%20replicas.%20These%20flow%20control%20gates%20do%20not%20affect%20t%3C%2FSPAN%3E%3CSPAN%20style%3D%22background%3A%20white%3B%22%3Ehe%20synchronization%20health%20state%20of%20the%20availability%20replicas%2C%20but%20they%20can%20affect%20the%20overall%20performance%20of%20your%20availability%20databases%2C%20including%20RPO.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20'Segoe%20UI'%3B%20font-size%3A%2012.0pt%3B%20color%3A%20%23171717%3B%22%3E%3CSPAN%20style%3D%22background%3A%20white%3B%22%3EAfter%20the%20logs%20have%20been%20captured%20on%20the%20primary%20replica%2C%20they%20are%20subject%20to%20two%20levels%20of%20flow%20controls%2C%20as%20shown%20in%20the%20table%20below.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CDIV%20style%3D%22direction%3A%20ltr%3B%22%3E%0A%3CTABLE%20style%3D%22direction%3A%20ltr%3B%20border-collapse%3A%20collapse%3B%20border%3A%201pt%20solid%20%23A3A3A3%3B%22%20title%3D%22%22%20border%3D%221%22%20summary%3D%22%22%20cellspacing%3D%220%22%20cellpadding%3D%220%22%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%3CTD%20style%3D%22vertical-align%3A%20top%3B%20width%3A%20.9118in%3B%20padding%3A%204pt%204pt%204pt%204pt%3B%20border%3A%201pt%20solid%20%23A3A3A3%3B%22%3E%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20'Microsoft%20YaHei'%3B%20font-size%3A%2011.0pt%3B%22%3ELevel%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20style%3D%22vertical-align%3A%20top%3B%20width%3A%202.0784in%3B%20padding%3A%204pt%204pt%204pt%204pt%3B%20border%3A%201pt%20solid%20%23A3A3A3%3B%22%3E%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20'Microsoft%20YaHei'%3B%20font-size%3A%2011.0pt%3B%22%3ENumber%20of%20Gates%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20style%3D%22vertical-align%3A%20top%3B%20width%3A%201.759in%3B%20padding%3A%204pt%204pt%204pt%204pt%3B%20border%3A%201pt%20solid%20%23A3A3A3%3B%22%3E%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20'Microsoft%20YaHei'%3B%20font-size%3A%2011.0pt%3B%22%3ENumber%20of%20messages%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20style%3D%22vertical-align%3A%20top%3B%20width%3A%203.984in%3B%20padding%3A%204pt%204pt%204pt%204pt%3B%20border%3A%201pt%20solid%20%23A3A3A3%3B%22%3E%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20'Microsoft%20YaHei'%3B%20font-size%3A%2011.0pt%3B%22%3EUseful%20Metrics%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20style%3D%22vertical-align%3A%20top%3B%20width%3A%20.9305in%3B%20padding%3A%204pt%204pt%204pt%204pt%3B%20border%3A%201pt%20solid%20%23A3A3A3%3B%22%3E%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20'Microsoft%20YaHei'%3B%20font-size%3A%2011.0pt%3B%22%3ETransport%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20style%3D%22vertical-align%3A%20top%3B%20width%3A%202.0784in%3B%20padding%3A%204pt%204pt%204pt%204pt%3B%20border%3A%201pt%20solid%20%23A3A3A3%3B%22%3E%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20'Microsoft%20YaHei'%3B%20font-size%3A%2011.0pt%3B%22%3E1%20per%20availabiltiy%20replica%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20style%3D%22vertical-align%3A%20top%3B%20width%3A%201.7402in%3B%20padding%3A%204pt%204pt%204pt%204pt%3B%20border%3A%201pt%20solid%20%23A3A3A3%3B%22%3E%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20'Microsoft%20YaHei'%3B%20font-size%3A%2011.0pt%3B%22%3E8192%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20style%3D%22vertical-align%3A%20top%3B%20width%3A%204.2187in%3B%20padding%3A%204pt%204pt%204pt%204pt%3B%20border%3A%201pt%20solid%20%23A3A3A3%3B%22%3E%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20'Microsoft%20YaHei'%3B%20font-size%3A%2011.0pt%3B%22%3E%3CSPAN%3EExtended%20event%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3Bdatabase_transport_flow_control_action%3C%2FSPAN%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20style%3D%22vertical-align%3A%20top%3B%20width%3A%20.9208in%3B%20padding%3A%204pt%204pt%204pt%204pt%3B%20border%3A%201pt%20solid%20%23A3A3A3%3B%22%3E%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20'Microsoft%20YaHei'%3B%20font-size%3A%2011.0pt%3B%22%3EDatabase%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20style%3D%22vertical-align%3A%20top%3B%20width%3A%202.0979in%3B%20padding%3A%204pt%204pt%204pt%204pt%3B%20border%3A%201pt%20solid%20%23A3A3A3%3B%22%3E%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20'Microsoft%20YaHei'%3B%20font-size%3A%2011.0pt%3B%22%3E1%20per%20availability%20database%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20style%3D%22vertical-align%3A%20top%3B%20width%3A%201.7402in%3B%20padding%3A%204pt%204pt%204pt%204pt%3B%20border%3A%201pt%20solid%20%23A3A3A3%3B%22%3E%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20'Microsoft%20YaHei'%3B%20font-size%3A%2011.0pt%3B%22%3E11200%20(x64)%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20'Microsoft%20YaHei'%3B%20font-size%3A%2011.0pt%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20'Microsoft%20YaHei'%3B%20font-size%3A%2011.0pt%3B%22%3E1600%20(x86)%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20style%3D%22vertical-align%3A%20top%3B%20width%3A%204.1145in%3B%20padding%3A%204pt%204pt%204pt%204pt%3B%20border%3A%201pt%20solid%20%23A3A3A3%3B%22%3E%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20'Microsoft%20YaHei'%3B%20font-size%3A%2011.0pt%3B%22%3E%3CA%20href%3D%22https%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fms179984(v%3Dsql.110)%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%3CSPAN%3EDBMIRROR_SEND%3C%2FSPAN%3E%3C%2FA%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20'Microsoft%20YaHei'%3B%20font-size%3A%2011.0pt%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20'Microsoft%20YaHei'%3B%20font-size%3A%2011.0pt%3B%22%3E%3CSPAN%3EExtended%20event%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3Bhadron_database_flow_control_action%3C%2FSPAN%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%3C%2FDIV%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20'Microsoft%20YaHei'%3B%20font-size%3A%2011.0pt%3B%22%3EFLOW%20CONTROL%20GATES%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20'Segoe%20UI'%3B%20font-size%3A%2012.0pt%3B%20color%3A%20%23171717%3B%22%3E%3CSPAN%20style%3D%22background%3A%20white%3B%22%3EOnce%20the%20message%20threshold%20of%20either%20gate%20is%20reached%2C%20log%20messages%20are%20no%20longer%20sent%20to%20a%20specific%20replica%20or%20for%20a%20specific%20database.%20These%20can%20be%20sent%20once%20acknowledgement%20messages%20are%20received%20for%20the%20sent%20messages%20to%20bring%20the%20number%20of%20sent%20messages%20below%20the%20threshold.%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20style%3D%22background%3A%20white%3B%22%3EIn%20addition%20to%20the%20flow%20control%20gates%2C%20there%20is%20another%20factor%20that%20can%20prevent%20the%20log%20messages%20from%20being%20sent.%20The%20synchronization%20of%20replicas%20ensures%20that%20the%20messages%20are%20sent%20and%20applied%20in%20the%20order%20of%20the%20log%20sequence%20numbers%20(LSN).%20Before%20a%20log%20message%20is%20sent%2C%20its%20LSN%20also%20checked%20against%20the%20lowest%20acknowledged%20LSN%20number%20to%20make%20sure%20that%20it%20is%20less%20than%20one%20of%20thresholds%20(depending%20on%20the%20message%20type).%20If%20the%20gap%20between%20the%20two%20LSN%20numbers%20is%20larger%20than%20the%20threshold%2C%20the%20messages%20are%20not%20sent.%20Once%20the%20gap%20is%20below%20the%20threshold%20again%2C%20the%20messages%20are%20sent.%3C%2FSPAN%3E%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EBlocked%20REDO%20thread%3C%2FSTRONG%3E%26nbsp%3B%20----%20When%20there%20are%20other%20issues%20or%20performance%20bottlenecks%20in%20secondary%20replica%2C%20the%20REDO%20thread%20can%20be%20blocked%20and%20cause%20latency%20of%20data%20synchronization.%20Refer%20document%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fsql-server%2Falwayson-minimizing-blocking-of-redo-thread-when-running%2Fba-p%2F383963%22%20target%3D%22_blank%22%3Ehttps%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fsql-server%2Falwayson-minimizing-blocking-of-redo-thread-when-running%2Fba-p%2F383963%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EShared%20REDO%20Target%3C%2FSTRONG%3E%26nbsp%3B%20-----%26nbsp%3B%20This%20issue%20only%20happens%20when%20you%20have%20multiple%20secondary%20replicas.%20When%20one%20secondary%20replica%20is%20very%20slow%20in%20finishing%20the%20redo%20process%2C%20it%20will%20limit%20the%20other%20secondary%20replicas%20in%20proceeding%20further%20on%20the%20maximum%20allowable%20LSN%20with%20the%20redo%20process.%20%3CSTRONG%3ETrace%20flag%209559%3C%2FSTRONG%3E%20can%20be%20used%20to%20mitigate%20the%20issue.%20(refer%20doc%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Farchive%2Fblogs%2Falwaysonpro%2Frecovery-on-secondary-lagging-shared-redo-target%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Farchive%2Fblogs%2Falwaysonpro%2Frecovery-on-secondary-lagging-shared-redo-target%3C%2FA%3E)%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3ERunning%20out%20of%20parallel%20redo%20threads%20in%20secondary%20replica%3C%2FSTRONG%3E%26nbsp%3B---%20When%20secondary%20replica%20is%20running%20out%20of%20parallel%20redo%20threads%2C%20you%20can%20use%20TF3478%20to%20allow%20maximal%20number%20of%20parallel%20redo%20thread%20to%20increase%20with%20total%20number%20of%20CPUs.%20By%20default%2C%26nbsp%3BA%20SQL%20Server%20instance%20uses%20up%20to%20100%20threads%20for%20parallel%20redo%20for%20secondary%20replicas.%20Each%20database%20uses%20up%20to%20one-half%20of%20the%20total%20number%20of%20CPU%20cores%2C%20but%20not%20more%20than%2016%20threads%20per%20database.%20If%20the%20total%20number%20of%20required%20threads%20for%20a%20single%20instance%20exceeds%20100%2C%20SQL%20Server%20uses%20a%20single%20redo%20thread%20for%20every%20remaining%20database.%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EDisk%20or%20I%2FO%20subsystem%20latency%20%3C%2FSTRONG%3E--%20%26gt%3B%20when%20the%20disk%20or%20I%2FO%20subsystem%20in%20the%20secondary%20replica%20has%20critical%20bottleneck%2C%20the%20redo%20rate%20will%20be%20impacted%20and%20quite%20small%20in%20secondary%20replica.%20We%20are%20less%20likely%20to%20see%20it%20in%20your%20secondary%20before%20it%20hit%20on%20primary%20if%20your%20secondary%20replica%20is%20not%20readable%20and%20has%20comparable%20hardware%20for%20SQL%20database%20files'%20storage%20as%20that%20in%20primary%20and%20dedicated%20for%20this%20SQL%20AG's%20usage.%20However%2C%20if%20your%20secondary%20replica%20has%20high%20volume%20of%20read-only%20workload%2C%20it%20can%20bring%20extra%20IO%20overhead%20to%20your%20IO%20subsystem.%26nbsp%3B%20Frequent%20database%20backup%20and%20VM%20snapshot%20can%20be%20another%20potential%20cause%20of%20extra%20I%2FO%20overhead.%26nbsp%3B%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22EstherXinMSFT_1-1636888132744.png%22%20style%3D%22width%3A%20721px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F326934iE5C999A63BAD330F%2Fimage-dimensions%2F721x452%3Fv%3Dv2%22%20width%3D%22721%22%20height%3D%22452%22%20role%3D%22button%22%20title%3D%22EstherXinMSFT_1-1636888132744.png%22%20alt%3D%22EstherXinMSFT_1-1636888132744.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2963083%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EHigh%20Availability%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPerformance%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESQL%202014%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Esql%202017%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESQL%202019%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Etroubleshooting%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Co-Authors
Version history
Last update:
‎Nov 14 2021 06:55 AM
Updated by: