Quantcast
Channel: SQL Archives - SQL Authority with Pinal Dave
Viewing all articles
Browse latest Browse all 594

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

$
0
0

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.

SELECT * 
FROM sys.master_files 
WHERE database_id = 2
GO
SELECT * 
FROM tempdb.sys.database_files
GO

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.

WORKAROUND/SOLUTION

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)

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


Viewing all articles
Browse latest Browse all 594

Trending Articles