SQL SERVER – Mismatch Between sys.database_files and sys.master_files For TempDB Database

SQL Server is a great product and sometimes some “By Design” behaviors cause interesting unexpected issues which is hard to understand unless you are an expert! In this blog, I would share my knowledge and findings of a situation where there was a mismatch between sys.database_files and sys.master_files for the TempDB database!

One of my existing clients contacted me and information that after restarting SQL Services they started seeing performance issue. I was engaged for performance consulting via my offering On-Demand (50 Minutes). We started GoToMeeting and started troubleshooting. In a short amount of time, I found that they were having contention in the TempDB database. I have them my recommendations to increase the files in the TempDB database. Interestingly, they told that they have already implemented this long ago.

Mismatch Between Files

I checked sys.master_files for tempdb database and sys.database_files.

FROM sys.master_files 
WHERE database_id = 2
FROM tempdb.sys.database_files

SQL SERVER - Mismatch Between sys.database_files and sys.master_files For TempDB Database tempdb-missing-01

As we can see above, there is a mismatch of information between those two catalog views. I checked the SQL Server ERRORLOG file and found the below messages.

  • Starting up database ‘tempdb’.
  • Error: 5123, Severity: 16, State: 1.
  • CREATE FILE encountered an operating system error 3(The system cannot find the path specified.) while attempting to open or create the physical file ‘F:\MoreTempDBFiles\temp1.ndf’.

This means that It looks like the functionality of SQL Server that when it is not able to create additional files for tempdb, it would create only 2 default files.


Based on my understanding, there is no way to add new files when SQL is running. We need to find the cause and fix the cause by looking at ERRORLOG and then fix that. Once the root cause is fixed, we need to restart the SQL Server service to get back all the files. In our error message, it was due to path missing. We created the path, restarted SQL Server service and all files were back.

Reference: Pinal Dave (https://blog.sqlauthority.com)

File format, SQL Error Messages, SQL Scripts, SQL TempDB
Previous Post
SQL SERVER – Improving Deployment Performance by SQL Server Monitoring
Next Post
SQL SERVER – SQL Azure Managed Instance Restore Error – The Database Was Backed Up on a Server Running Version 15.00.2000

Related Posts

Leave a Reply