Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SQL Server Administration (2008)
 The transaction log for database x is full

Author  Topic 

theboyholty
Posting Yak Master

226 Posts

Posted - 2011-03-24 : 06:09:26
I just tried to run an insert statement for one of my database tables and recieved this error:

The transaction log for database x is full. To find out why space in the log cannot be reused, see the log_reuse_wait_desc column in sys.databases.

So I ran
SELECT Name,Log_Reuse_Wait,Log_Reuse_Wait_Desc 
FROM sys.databases
and got the following result:

Log_Reuse_Wait Log_Reuse_Wait_Desc
2 LOG_BACKUP

Trouble is, I don't know what this means or how to resolve it. I'm not a DBA so I've never bothered about Transaction Logs and such things. I don't want to pester one of our DBAs until I think I know what I'm on about or whether I've caused this. I have been running some faitrly big updates / inserts (1.3 million rows) but its nothing I haven't done before.


---------------------------------------------------------------------------------
http://www.mannyroadend.co.uk The official unofficial website of Bury Football Club

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-03-24 : 06:21:10
You're definitely going to need to contact the DBA for this. The DBA needs to check the transaction log: recovery model + backups.

Your big updates are likely the culprit. You'll either need to break it up into smaller batches or the DBA needs to expand the tlog (perhaps a disk space issue or tlog isn't set to autogrow).

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2011-03-24 : 08:37:54
What I would suggest is take you take a FULL Backup,Set recovery model to SIMPLE and then insert your records.After insertion take a differential backup (so that you do not loose the data had been BULK inserted if you need a backup in case of failure) and then again set the Recovery model to FULL.


Remember TAKE A FULLBACKUP BEFORE INSERTION AND DIFFERENTIAL BACKUP AFTER INSERTION.

Also do you have any existing backup strategy ?

PBUH

Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2011-03-24 : 10:06:19
Is this a production database? If so, go and bother the DBA and do not mess with recovery models. If you do and something goes wrong afterwards it could result in major data loss and it would be your fault.

If this is a development database, and you do not need the ability to restore the DB to point-in-time (to the actual moment of failure), then you can change it to simple recovery. But do some reading on recovery models.

Maybe start with this - [url]http://www.sqlservercentral.com/articles/64582/[/url]

--
Gail Shaw
SQL Server MVP
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-03-24 : 12:03:53
I don't see the point of switching recovery models for a large update/insert. It is still a logged operation and will require the same amount of space in the tlog whether SIMPLE, FULL, or BULK_LOGGED.


Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2011-03-24 : 14:10:58
Not for a single operation.

I mainly wanted to emphasise that if it's a prod database then there's no way in hell that the recovery model should be changed without the DBA's knowledge.

--
Gail Shaw
SQL Server MVP
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-03-24 : 14:45:28
Sorry, I was referring to Sachin's post. I should've quoted it in my reply.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

theboyholty
Posting Yak Master

226 Posts

Posted - 2011-03-25 : 10:41:31
Thanks for all your replies. It is a production database. I asked one of the DBAs and he shrank the transaction log for the database and freed up some space. Shows what I know becasue I would have thought shrinking it would make the problem worse.

Its all good now.

---------------------------------------------------------------------------------
http://www.mannyroadend.co.uk The official unofficial website of Bury Football Club
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2011-03-25 : 10:59:59
Shrinking's the complete wrong approach if that's the only thing he did.
Now, if he shrank after resolving whatever was wrong, that's maybe OK.

Otherwise maybe have your DBA read this? http://www.sqlservercentral.com/articles/64582/

--
Gail Shaw
SQL Server MVP
Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2011-03-25 : 23:06:39
quote:
Originally posted by GilaMonster

Not for a single operation.




What did you meant by that ?

PBUH

Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-03-25 : 23:28:25
Switching the recovery model to SIMPLE will have no different to FULL or BULK_LOGGED with a single transaction. But if you break up the large transaction into many smaller transactions, then there will be a difference between the recovery models as far as the transaction log goes.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2011-03-26 : 01:44:06
Thanks Tara for clarifying that.

Can anyone post first few steps one should take in case of such a situation i.e log files getting FULL? I mean what should be the initial approach or is the answer "it depends" .

PBUH

Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-03-26 : 02:15:09
1. Is it due to a large transaction?
2. What's the recovery model for the database?
3. If it's not SIMPLE, then how often are tlog backups running?
4. Disk space problem?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2011-03-26 : 02:42:44
Tara,

I believe what you have posted is the root cause analysis.I wanted to know the immediate steps on the ways to bring down the log size once it has bloated to such a level.

PBUH

Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-03-26 : 03:09:41
Well whether or not you shrink the file down is dependent upon the root cause. If you plan on shrinking it, then you use DBCC SHRINKFILE.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2011-03-26 : 06:54:39
quote:
Originally posted by Sachin.Nand

Thanks Tara for clarifying that.

Can anyone post first few steps one should take in case of such a situation i.e log files getting FULL?


Sure, I happen to have an entire article on that;
http://www.sqlservercentral.com/articles/Transaction+Log/72488/

--
Gail Shaw
SQL Server MVP
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2011-03-26 : 06:55:25
quote:
Originally posted by Sachin.Nand

Tara,

I believe what you have posted is the root cause analysis.I wanted to know the immediate steps on the ways to bring down the log size once it has bloated to such a level.


Errr, if you don't know why it's full, how do you expect to be able to fix it?

--
Gail Shaw
SQL Server MVP
Go to Top of Page
   

- Advertisement -