Sqlserver2016启用了日志并行,但是实际上某些数据库日志并行并没有生效的问题

https://docs.microsoft.com/en-us/archive/blogs/sql_server_team/sql-server-20162017-availability-group-secondary-replica-redo-model-and-performance

sqlserver2016默认启动并行

禁用并行2种方法
1、DBCC TRACEON (3459, -1),不用重启sqlserver服务
2、-T 3459参数加入sqlserver启动参数

禁用串行再启用并行,必须重启sqlserver
如果有-T 3459参数,则移除该参数,再重启sqlserver
如果是DBCC TRACEON (3459, -1), 则直接重启sqlserver

现象:wondadb3上有20来个数据库做了AG到dbprod126,dbprod126只有24个CPU,发现wondadb3.wondb到dbprod126.wondb的AG传输很慢,把所有数据库移出AG,再重新加入,加入的过程中第一个先加入wondb,在加入其它所有数据库,发现wondadb3.wondb到dbprod126.wondb的AG传输快了很多,发现sqlserver2016的并行设计上有缺陷,数据库数量一多,排后面的几个数据库就只能默认使用串行

官方文档的解释:
Parallel redo thread usage is well covered in “Thread usage by Availability Groups” here.

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.

When the host server has 32 or more CPU cores, each database will occupy 16 parallel redo worker threads and one helper worker thread. It means that all databases starting with the 7th database (ordered by database id ascending) that has joined availability group it will be in single thread redo or serial redo irrespective which database has actual redo workload. If a SQL Server Instance has a number of databases, and it is desired for a particular database to run under parallel redo model, the database creation order needs to be considered. Same idea can be
applied to force a database always runs in serial redo model as well. Again, in SQL Server instance level, the way to switch between parallel redo and serial redo is the TF 3459. All databases in the same SQL Server instance will be switched together. Also, to switch from serial redo to parallel redo by disable TF 3459, a SQL Server service restart is required

Guess you like

Origin blog.csdn.net/lusklusklusk/article/details/113782118