Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 908
  • Last Modified:

SQL Server 2005 LDF will not shrink

I have a SQL 2005 database with a rapidly-expanding logfile that I cannot get to stay at a reasonable size.  

- LDF has already filled disk once, forcing me to Detach, delete & then re-attach db
- Two days later it's already back up to 12 gig and growing steadily.
- Recovery model is already set to Simple.  Switching to Full then back to Simple has no effect.
- Daily maintenance plan including a Shrink, which has no apparent effect.
- Manually executing dbcc ShrinkFile('hydroweb_log',2) also has no effect, but returns the following:

Dbld  Field  CurrentSize   MinimumSize   UsedPages    EstimatedPages
10       2        1409936       128                     1409936         128

I'm not seeing anything unusual in the logs, nor any unusual activity in the monitor.
0
hydrofarm
Asked:
hydrofarm
  • 3
  • 2
  • 2
  • +3
2 Solutions
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
please show the output of DBCC OPENTRAN on this database?
0
 
David ToddSenior DBACommented:
Hi,

If your running simple recovery model and log is still growing, then you have some very long running transactions. That is what AngelIII is getting you to look for.

Does a
backup log with no_log help any? I imagine not much if at all in this instance.

Regards
  David
0
 
Vitor MontalvãoMSSQL Senior EngineerCommented:
Can also be reindex job. Depends how big are the tables.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
Chris MConsulting - Technology ServicesCommented:
Try looking up long running transactions which could be making your log file grow.
The size of the log file for a database in simple recovery mode is dependent on a number of factors like:
- Length of transactions (long running transactions will grow the logs)
- Nature of transactions (transactions with lots of looping before a commit will grow the logs)
- Type of transactions (database maintenance exercises like reindexing huge tables grow the logs)

The best way of understanding your database system is by looking at the transactions which grow so that you're able to identify which ones grow the log most.

Launch SQL profiler to look at the nature of your transactions.
View sessions in SMSS process monitor to see the long running sessions.

Look at tempdb
Query against sysprocesses table (master db) to see the long running queries possibly you could get a hint.

Later on you might realise that your database actually requires more disk spacer because of this nature of transactions.

Also note that choosing the recovery model of your database should not be based on the disk free space available but it should be based on how critical your data is and then let the business buy more space since it has critical data.

Regards,
Chris Musasizi

0
 
Chris MConsulting - Technology ServicesCommented:
I know you did not say this but if your log file has some space in it and you simply cannot free it by shrinking the file using DBCC SHRINKFILE, then you might have to first of all grow it by say 1 MB, then shrinking will work for you.

All the best.

Regards,
Chris Musasizi.
0
 
hydrofarmAuthor Commented:
Here is the output of DBCC OPENTRAN:

Replicated Transaction Information:
        Oldest distributed LSN     : (0:0:0)
        Oldest non-distributed LSN : (799344:175:1)
DBCC execution completed. If DBCC printed error messages, contact your system administrator.

One recent change that might be a suspect here is replication - I recently configured snapshot (not transactional) replication of some tables to another server.  Could that be the issue, even though I configured to create a snapshot only once a day?

sysprocesses.csv
0
 
Vitor MontalvãoMSSQL Senior EngineerCommented:
Databases that are in replication process need to be in full recovery mode, so that's explain why your transaction log grows a lot.
You need to make regular transaction log backups so you can empty LDF file.
0
 
hydrofarmAuthor Commented:
Ok, thanks for the info regarding replication vs. recovery mode.  However, when running the following:

BACKUP LOG hydroweb WITH TRUNCATE_ONLY
DBCC SHRINKFILE(hydroweb_log, 1)

I get this error -

Cannot shrink log file 2 (hydroweb_log) because all logical log files are in use.

Is the replication process preventing nightly shrink and ultimately causing my bloated LDF?
0
 
Anthony PerkinsCommented:
>>LDF has already filled disk once, forcing me to Detach, delete & then re-attach db<<
This is a very bad idea.  You are risking corrupting your database.

>>Is the replication process preventing nightly shrink and ultimately causing my bloated LDF?<<
It is likely or the absense of any type of Transaction Log backups would also do it.
0
 
hydrofarmAuthor Commented:
Ok, I think I may have this resolved.  I cleared the replication queue on the db I was having trouble with (which also recently became a replication publisher.)

EXEC sp_repldone @xactid = NULL, @xact_segno = NULL,  @numtrans = 0, @time = 0, @reset = 1

Then did a log backup & shrink, which emptied my LDF.  I'll give it a few days and see if it was just a replication glitch that occurred while I was setting things up.  If not I'll re-post as a question re: replication.
0
 
Anthony PerkinsCommented:
>>Then did a log backup & shrink, which emptied my LDF.<<
Because of the number of times you have had to shrink the Transaction Log it must be highly fragmented, I would recommend you get that resolved as soon as possible or performance will not be optimal.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 3
  • 2
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now