Inconsistency between sys.database_files and sys.master_files

  • I tried to shrink the log file on one of our databases but after running the following

    USE [JKV_DATA]

    GO

    DBCC SHRINKFILE (N'JKV_DATA_log' , 0, TRUNCATEONLY)

    GO

    I got error message


    Msg 8985, Level 16, State 1, Line 1

    Could not locate file 'JKV_DATA_log' for database 'JKV_DATA' in sys.database_files. The file either does not exist, or was dropped.


    So I ran

    USE JKV_DATA

    GO

    SELECT df.type_desc, df.[name], df.physical_name FROM sys.database_files df

    SELECT mf.type_desc, mf.[name], mf.physical_name FROM sys.master_files mf WHERE mf.database_id = DB_ID('JKV_DATA')

    to see what could possibly gone wrong and got

    type_descnamephysical_name

    ROWSJKV_DATAE:\Databases\JKV_DATA.mdf

    LOGbuscom_logE:\Databases\JKV_DATA_log.ldf

    type_descnamephysical_name

    ROWSJKV_DATAE:\Databases\JKV_DATA.mdf

    LOGJKV_DATA_logE:\Databases\JKV_DATA_log.ldf

    The logical names of the log file do not match. To make things even worse, I can neither rename nor drop it. And I cannot shrink it either.

    How could this happen? Is there a quick fix?

  • Did you ever fix this? I had the same issue after doing an inplace upgrade from 2008 R2 to 2012 RTM...

    Someone said there was a fix issued for 2008 R2... but, I hadn't applied it before the upgrade,,,

    Curious?

  • I can't remember anything we did to fix that but after a quick check the issue isn't present anymore, so someone obviously did manage to put things right.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply