Error 5149 while attempting expand physical file.
Applies to: Microsoft SQL Server 2016.
Date created: October 29, 2022.
Problem Description.
When attempting to increase the size of a database secondary file by a few
gigabytes, I got the error message below:
Alter failed for database. (Microsoft.SqlServer.Smo)
Additional information:
An exception occurred while executing a Transact-SQL statement or batch/
(Microsoft.SqlServer.ConnectionInfo)
MODIFY FILE encountered operating system error 112(There is not enough space on
the disk.)
while attempting to expand the physical file
(Microsoft SQL Server, Error: 5149)
However, when I tried to increase the size 300 MB, I was able to do it
successfully.
All this was occurring on a terabyte size disk drive with 700 GB of free
space.
Cause.
The reason for this behavior was the organization implemented
Access Protection Rules provided by McAfee Endpoint Security. Those
should be enabled during a virus outbreak and for workstations only, but on this
scenario were enabled on a database server.
See below error that was found on the Application log of the operating
system:
EventId 3 Error McAfee Endpoint Security
Event ID=1095
NT AUTHORITY\SYSTEM ran SYSTEM:REMOTE\SYSTEM:REMOTE, which accessed \\.\pipe\CAInvokerService,
violating the rule "Remotely creating or modifying files or folders". Access was
allowed because the rule wasn't configure to block.
Workaround/Solution.
The workaround is to increase the database file in small chunks like 300 MB or
500 MB.
The definitive solution is to remove those policies from any Production
server. These rules should be enabled during a virus outbreak and for
workstations only.