Could Not Allocate Space Because the Filegroup Is Full (Error 1105)

🚨Part of the SQL Server Errors series, the exact messages and what actually causes them.

Msg 1105  ·  Level 17  ·  State 2
Could not allocate space for object ‘dbo.Orders’.’PK_Orders’ in database ‘YourDb’ because the ‘PRIMARY’ filegroup is full. Create disk space by deleting unneeded files, dropping objects in the filegroup, adding additional files to the filegroup, or setting autogrowth on for existing files in the filegroup. Msg 1105, Level 17, State 2
Check autogrowth before you look at the disk. A file with growth switched off or a MAXSIZE cap will fill with the volume half empty, and volume monitoring never sees it coming. The message names the filegroup to check.

This is the data file, not the log. If you have arrived here after reading about transaction log full, that is a different error (9002) with a completely different fix, and taking a log backup will do nothing for this one.

The message helpfully lists four possible fixes without telling you which one you need. The difference matters, because two of them are fine and two of them are how people make things worse.


Find Out Which Kind of Full It Is

There are three, and they look identical from the error:

SELECT  f.name              AS logical_name,
        f.physical_name,
        fg.name             AS filegroup_name,
        f.size / 128.0                                   AS size_mb,
        CAST(FILEPROPERTY(f.name, 'SpaceUsed') AS INT) / 128.0 AS used_mb,
        (f.size - CAST(FILEPROPERTY(f.name, 'SpaceUsed') AS INT)) / 128.0 AS free_mb,
        f.growth,
        f.is_percent_growth,
        CASE f.max_size
             WHEN -1 THEN 'unlimited'
             WHEN  0 THEN 'no growth'
             ELSE CAST(f.max_size / 128 AS VARCHAR(20)) + ' MB cap'
        END                 AS max_size
FROM    sys.database_files f
JOIN    sys.filegroups fg ON fg.data_space_id = f.data_space_id
WHERE   f.type_desc = 'ROWS';

Read it in this order:

  • growth is 0. Autogrowth is switched off. The file will never grow, however much disk you have. This is the most common cause and the least obvious, because the disk looks fine.
  • max_size is a cap and used has reached it. The file hit a ceiling somebody set deliberately, or a ceiling nobody knew about.
  • growth is set and max_size is unlimited. Then it tried to grow and could not, which means the disk is out of space.

Check the Disk Before Changing Anything

SELECT DISTINCT
       vs.volume_mount_point,
       vs.total_bytes  / 1073741824.0 AS total_gb,
       vs.available_bytes / 1073741824.0 AS free_gb,
       CAST(vs.available_bytes * 100.0 / vs.total_bytes AS DECIMAL(5,1)) AS pct_free
FROM   sys.master_files mf
CROSS APPLY sys.dm_os_volume_stats(mf.database_id, mf.file_id) vs;

If the volume has room and the file still will not grow, it is autogrowth or a cap. If the volume is full, no setting change will help and you need space first.


The Fixes, and Which To Reach For

Autogrowth Is Off, or the Cap Is Reached

ALTER DATABASE [YourDb]
MODIFY FILE (NAME = N'YourDb', FILEGROWTH = 512MB, MAXSIZE = UNLIMITED);

Set growth in megabytes, not percent. Percentage growth on a large file means each growth is bigger than the last, and every one of them is a pause while the file extends.

The Disk Is Genuinely Full

Add a file on a different volume rather than fighting for space on a full one:

ALTER DATABASE [YourDb]
ADD FILE (NAME = N'YourDb_2',
          FILENAME = N'E:\Data\YourDb_2.ndf',
          SIZE = 8GB, FILEGROWTH = 512MB)
TO FILEGROUP [PRIMARY];

SQL Server spreads new allocations across files in the filegroup, so this relieves the pressure immediately.

A second file is a real decision, not a quick fix. It stays part of the database forever and it has to be backed up, restored and managed with it. If it is genuinely temporary, plan how it comes back out.

What Not To Do

Do not shrink another database to make room. It causes index fragmentation, the space comes back almost immediately, and you now have two problems.

Do not delete data to free space in a hurry. A delete inside a transaction needs log space and frees no data-file space until the pages are deallocated, so it can make the outage worse at the exact moment you need it not to.


When It Is Not Really About Space

A file with plenty of free space that still throws 1105 usually means the free space is in the wrong place:

  • A different filegroup. The object lives in a filegroup that is full while PRIMARY has room, or the reverse. The error names the filegroup, so read it rather than assuming PRIMARY.
  • TempDB. The same error against tempdb is a different conversation, usually a query spilling far more to disk than anyone expected.
  • Uneven files. Several files in the filegroup, one full and the others not, because they were added at different sizes. SQL Server fills proportionally to free space, so a small new file gets hammered.

Stopping It Recurring

  • Alert on free space inside the file, not just on the volume. A file with autogrowth off can be full on a half-empty disk, and volume monitoring will never see it.
  • Size files for the year ahead and leave them there. Autogrowth is a safety net, not a capacity plan, and every growth event is a pause.
  • Turn on Instant File Initialization so data file growth is near-instant rather than a stall while the file is zeroed.
  • Check growth = 0 across the estate. It is usually a leftover from a restore or a template database, and nobody finds it until the file fills.

Common Questions

Is this the same as the transaction log being full?
No, and it is the most common confusion. 1105 is the data file, 9002 is the log. Taking a log backup does nothing for 1105.
The disk has plenty of space, so why is the file full?
Autogrowth is almost certainly switched off, or the file has hit a MAXSIZE cap. A file with growth = 0 will never grow no matter how much disk is free, and volume monitoring will never see it coming.
Should I add a second data file?
It is the right answer when the volume is genuinely full, because SQL Server spreads new allocations across files. But it is a permanent decision: the file has to be backed up, restored and managed forever after. If it is meant to be temporary, plan how it comes back out.

Related Scripts

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *