HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Database Log File Growth change does not reflect on secondary replica sys.master_files

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
master_filesreflectfilelogreplicadatabasesecondarysysgrowthdoes

Problem

Environment: Microsoft SQL Server 2014 - 12.0.4100.1 (X64) Apr 20 2015 17:29:27 Copyright (c) Microsoft Corporation Enterprise Edition (64-bit) on Windows NT 6.3 (Build 9600: ) (Hypervisor)

When I change the log file growth rate on primary replica, secondary replica database get that change and I can verify from GUI and sys.database_files view. But same change does not reflect in sys.master_files view.

Set up code

```
:Connect PrimaryNode

IF EXISTS(SELECT name FROM sys.databases
WHERE name = 'FileGrowthTest]')
DROP DATABASE FileGrowthTest
GO
CREATE DATABASE [FileGrowthTest]
ON PRIMARY
( NAME = N'FileGrowthTest', FILENAME = N'L:\FileGrowthTest.mdf' , SIZE = 4096KB , FILEGROWTH = 10%)
LOG ON
( NAME = N'FileGrowthTest_log', FILENAME = N'F:\FileGrowthTest_log.ldf' , SIZE = 4096KB , FILEGROWTH = 10%)
GO

BACKUP DATABASE [FileGrowthTest] TO
DISK = N'E:\Backup\FileGrowthTest.bak'
WITH NOFORMAT, NOINIT, NAME = N'FileGrowthTest-Full Database Backup',
SKIP, NOREWIND, NOUNLOAD, STATS = 10
GO

--- YOU MUST EXECUTE THE FOLLOWING SCRIPT IN SQLCMD MODE.
:Connect PrimaryNode

USE [master]

GO

ALTER AVAILABILITY GROUP [TestAG]
ADD DATABASE [FileGrowthTest];

GO

:Connect PrimaryNode

BACKUP DATABASE [FileGrowthTest] TO DISK = N'\\backupshare\FileGrowthTest.bak' WITH COPY_ONLY, FORMAT, INIT, SKIP, REWIND, NOUNLOAD, COMPRESSION, STATS = 5

GO

:Connect SecondaryNode

RESTORE DATABASE [FileGrowthTest] FROM DISK = N'\\backupshare\FileGrowthTest.bak' WITH NORECOVERY, NOUNLOAD, STATS = 5

GO

:Connect PrimaryNode

BACKUP LOG [FileGrowthTest] TO DISK = N'\\backupshare\FileGrowthTest.trn' WITH NOFORMAT, INIT, NOSKIP, REWIND, NOUNLOAD, COMPRESSION, STATS = 5

GO

:Connect SecondaryNode

RESTORE LOG [FileGrowthTest] FROM DISK = N'\\backupshare\FileGrowthTest.trn' WITH NORECOVERY, NOUNLOAD, STATS = 5

GO

:Connect SecondaryNode

-- Wait for the replica to start communicating
begin try
declare @conn bit
declare @count int
declare @replica_

Solution

This is a known issue, I suspect that master on the secondary won't be written to immediately, and perhaps not at all until that instance becomes the primary. The issue is still "under review" according to this bug filed by Nic Cain back in 2015:

  • sys.master_files catalog view for TLOG growth is not updated on an AG secondary



Until this is addressed, I recommend using sys.database_files instead of sys.master_files, though I know this isn't always convenient.

Also see this forum thread, this forum thread, and Nic's blog post about this issue.

Context

StackExchange Database Administrators Q#220376, answer score: 3

Revisions (0)

No revisions yet.