Pergunta

I have a 225GB DB with a 390GB log file, which has only recently exploded in size. I am trying to shrink it - per these instructions: https://www.brentozar.com/blitz/transaction-log-larger-than-data-file/

I am not able to Shrink it on SSMS or by the DBCC SHRINKFILE command. I tried waiting until it was not in use, and also tried a Log backup then running the DBCC SHRINKFILE again, but to no avail. Any ideas on what I can do?

I saw in this article (https://www.mssqltips.com/sqlservertutorial/3311/how-to-shrink-the-transaction-log/) that it says I could try flipping the recovery model over to Simple, run the shrink, then flip it back to Full, but that sounds risky to me so I am cautious to try that.

Also worth noting is that my database is Mirroring and currently stuck in a Suspended state.

Wondering if you guys could lend any advice. We are your typical DBA-less shop, so I appreciate any novice-conscience pointers or suggestions! Thanks!

Foi útil?

Solução

Your log_reuse_wait_desc is database_mirroring and you mentioned it currently stuck in a Suspended state

select name, log_reuse_wait_desc from sys.databases

You should find a cause your mirroring was suspended. Try to search messages that include Database mirroring has been suspended in ERRORLOG file on the principal. It could be like one below:

2019-08-13 11:40:48.98 spid64s Error: 1453, Severity: 16, State: 1.

2019-08-13 11:40:48.98 spid64s 'TCP://xxx.com:5022', the remote mirroring partner for database 'DB', encountered error 5149, status 3, severity 25. Database mirroring has been suspended. Resolve the error on the remote server and resume mirroring, or remove mirroring and re-establish the mirror server instance.

Using error number you are able to get its description from sys.messages:

select * from sys.messages where message_id = 5149

This case:

MODIFY FILE encountered operating system error %ls while attempting to expand the physical file '%ls'.

That means there is not enough physical space to expand a file on the mirror.

After solving any found errors you have to turn on your mirroring. Run on the principal:

ALTER DATABASE YourDBName SET PARTNER RESUME;

In case you won't be able to find any related errors in ERRORLOG, just try to resume your mirroring using a command above and then look after the database and check your ERRORLOG for errors once the mirrored database goes to the suspended state (if it does).

Outras dicas

Right click the database select Reports -> Standard Reports -> Disk Usage to check transaction log file is empty or full. If it is full, run following command to check what it is waiting for.

select name,log_reuse_wait_desc from sys.databases
Licenciado em: CC-BY-SA com atribuição
Não afiliado a dba.stackexchange
scroll top