Home
%3CLINGO-SUB%20id%3D%22lingo-sub-371068%22%20slang%3D%22en-US%22%3ETempdb%20misconfiguration%20when%20SQL%20Server%20fails%20to%20create%20a%20secondary%20data%20file%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-371068%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSTRONG%3EFirst%20published%20on%20MSDN%20on%20Nov%2010%2C%202016%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3EOne%20of%20the%20%3CA%20href%3D%22https%3A%2F%2Fsupport.microsoft.com%2Fen-us%2Fkb%2F2154845%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%20tempdb%20best%20practices%20%3C%2FA%3E%20when%20you%20configure%20SQL%20Server%20is%20to%20create%20additional%20data%20files%20for%20tempdb%20according%20the%20number%20of%20logical%20processor%20per%20NUMA%20node%20up%20to%20eight.%20Even%20with%20%3CA%20href%3D%22https%3A%2F%2Fblogs.msdn.microsoft.com%2Fpsssql%2F2016%2F03%2F17%2Fsql-2016-it-just-runs-faster-automatic-tempdb-configuration%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%20SQL%20Server%202016%20%3C%2FA%3E%20you%20can%20specify%20the%20creation%20of%20those%20secondary%20datafiles%20at%20installation%20time.%20Well%2C%20a%20few%20days%20ago%2C%20reviewing%20a%20customer%20environment%20I%20found%20something%20curious%2C%20look%20at%20this%20screenshots%3A%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20569px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F89890i479C47A0F41BE48E%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20%2F%3E%3C%2FSPAN%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20407px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F89891iEDA42F32182884EA%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20%2F%3E%3C%2FSPAN%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3EAs%20you%20can%20see%20sys.master_files%20is%20reporting%203%20datafiles%20for%20tempdb%20%2B%201%20logfile%20meanwhile%20sys.database_files%20is%20showing%20up%20only%201%20datafile%20%2B%201%20logfile.%20%3CBR%20%2F%3E%3CBR%20%2F%3EWhen%20the%20SQL%20Server%20service%20is%20starting%20initializes%20tempdb%2C%20this%20means%20that%20deletes%20old%20files%20and%20create%20new%20ones%2C%20if%20you%20look%20at%20the%20errorlog%20you%20can%20see%3A%3C%2FP%3E%0A%3CPRE%3EStarting%20up%20database%20'tempdb'.%20%3C%2FPRE%3E%0A%3CP%3E%3CBR%20%2F%3EThen%20I%20looked%20for%20the%20files%3A%20%3C%2FP%3E%0A%0A%3CTABLE%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%3CTD%3EF%3A%5Cdata%5Ctempdev_sql14.ndf%20%3CBR%20%2F%3ED%3A%5Ctempdb2%5Ctempdev100.ndf%20%3C%2FTD%3E%0A%3CTD%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20260px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F89892i8698224D7E7809EA%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20%2F%3E%3C%2FSPAN%3E%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%0A%0A%0A%3CP%3E%3CBR%20%2F%3EAgain%2C%20looking%20at%20the%20error%20log%20we%20can%20find%3A%20%3C%2FP%3E%0A%3CPRE%3E%0A2016-10-22%2000%3A00%3A51.810%20spid10s%20Error%3A%205123%2C%20Severity%3A%2016%2C%20State%3A%201.%0A2016-10-22%2000%3A00%3A51.810%20spid10s%20CREATE%20FILE%20encountered%20operating%20system%20error%203(The%20system%20cannot%20find%20the%20path%20specified.)%20while%20attempting%20to%20open%20or%20create%20the%20physical%20file%20'd%3A%5Ctempdb2%5Ctempdev100.ndf'.%0A%3C%2FPRE%3E%0A%0A%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20422px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F89896i041E6065E5611A5E%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20%2F%3E%3C%2FSPAN%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSTRONG%3E%20Facts%20%3CBR%20%2F%3E%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EAt%20startup%20when%20SQL%20Server%20fails%20to%20create%20an%20additional%20data%20file%20(.ndf)%2C%20if%20single%20error%20occurs%20SQL%20Server%20removes%20the%20reference%20to%20the%20all%20additional%20data%20files%20(.ndf)%20but%20it's%20able%20to%20start%20tempdb%20with%20the%20minimal%20configuration%20.mdf%20and%20.ldf.%20This%20can%20follow%20to%20performance%20issues%20and%20tempdb%20contention.%3C%2FLI%3E%0A%3CLI%3EAt%20startup%20when%20SQL%20Server%20fails%20to%20create%20the%20.mdf%20or%20the%20.ldf%20a%20major%20error%20occurs%20and%20the%20instance%20is%20shutted%20down.%3C%2FLI%3E%0A%3CLI%3EValidate%20the%20path%20and%20permissions%20of%20the%20SQL%20Server%20service%20account%20to%20create%20the%20file%20'd%3A%5Ctempdb2%5Ctempdev100.ndf'%3C%2FLI%3E%0A%3CLI%3EOr%20simply%20remove%20the%20logical%20file%20and%20then%20create%20an%20additional%20data%20file%20in%20a%20valid%20location.%0A%3CPRE%3E%0AALTER%20DATABASE%20%5Btempdb%5D%20REMOVE%20FILE%20tempdevsql100%0AGO%0AALTER%20DATABASE%20%5Btempdb%5D%20ADD%20FILE%20(%20NAME%20%3D%20N'tempdevsql100'%2C%20FILENAME%20%3D%20N'F%3A%5Cdata%5Ctempdev100.ndf'%20%2C%20SIZE%20%3D%20256MB%20%2C%20FILEGROWTH%20%3D%2064MB%20)%3C%2FPRE%3E%0A%3C%2FLI%3E%0A%3C%2FUL%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-371068%22%20slang%3D%22en-US%22%3E%3CP%3EFirst%20published%20on%20MSDN%20on%20Nov%2010%2C%202016%20One%20of%20the%20tempdb%20best%20practices%20when%20you%20configure%20SQL%20Server%20is%20to%20create%20additional%20data%20files%20for%20tempdb%20according%20the%20number%20of%20logical%20processor%20per%20NUMA%20node%20up%20to%20eight.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-371068%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3Etempdb%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

First published on MSDN on Nov 10, 2016
One of the tempdb best practices when you configure SQL Server is to create additional data files for tempdb according the number of logical processor per NUMA node up to eight. Even with SQL Server 2016 you can specify the creation of those secondary datafiles at installation time. Well, a few days ago, reviewing a customer environment I found something curious, look at this screenshots:





As you can see sys.master_files is reporting 3 datafiles for tempdb + 1 logfile meanwhile sys.database_files is showing up only 1 datafile + 1 logfile.

When the SQL Server service is starting initializes tempdb, this means that deletes old files and create new ones, if you look at the errorlog you can see:

Starting up database 'tempdb'. 


Then I looked for the files:

F:\data\tempdev_sql14.ndf
D:\tempdb2\tempdev100.ndf


Again, looking at the error log we can find:

2016-10-22 00:00:51.810 spid10s Error: 5123, Severity: 16, State: 1.
2016-10-22 00:00:51.810 spid10s CREATE FILE encountered operating system error 3(The system cannot find the path specified.) while attempting to open or create the physical file 'd:\tempdb2\tempdev100.ndf'.


Facts


  • At startup when SQL Server fails to create an additional data file (.ndf), if single error occurs SQL Server removes the reference to the all additional data files (.ndf) but it's able to start tempdb with the minimal configuration .mdf and .ldf. This can follow to performance issues and tempdb contention.
  • At startup when SQL Server fails to create the .mdf or the .ldf a major error occurs and the instance is shutted down.
  • Validate the path and permissions of the SQL Server service account to create the file 'd:\tempdb2\tempdev100.ndf'
  • Or simply remove the logical file and then create an additional data file in a valid location.
    ALTER DATABASE [tempdb] REMOVE FILE tempdevsql100
    GO
    ALTER DATABASE [tempdb] ADD FILE ( NAME = N'tempdevsql100', FILENAME = N'F:\data\tempdev100.ndf' , SIZE = 256MB , FILEGROWTH = 64MB )