• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 341
  • Last Modified:

SQL Transaction Logs filling up

I'm running a query that inserts about 500,000 rows into a table.  The query fails with this error:
Msg 9002, Level 17, State 4, Line 1
The transaction log for database 'database' is full. To find out why space in the log cannot be reused, see the log_reuse_wait_desc column in sys.databases

This happens even if I run dbcc shrinkfile right before I run this query.  I've tried this in both Simple recovery mode and Full recovery mode, with the same result.

From what I can tell, the transaction log isn't truncating because it is filling up in the middle of one active transaction.  What do I do in this instance?
  • 2
1 Solution
Guy Hengel [angelIII / a3]Billing EngineerCommented:
Make sure you have a big transaction log file.
Shrinking the file is contra productive.

Make sure that if you are in full recovery mode you run regular transaction log backup

Make sure that any ON INSERT trigger on the table is tuned or eventually disabled

Make sure your instance allows you big db files.

Test if you could do the insert in bulk logged mode
MSECAuthor Commented:
Thanks!  Growing the file beforehand worked.  It seems strange to me, since it was set to unrestricted growth in the first place, but the query ran successfully anyway.
Guy Hengel [angelIII / a3]Billing EngineerCommented:
growing the db file is part of the transaction, but if that takes too long (because of too much IO at once), the growing will "fail", and hence so your transaction.
the error message is misleading, because indeed the file is (still) too small, but actually the growing failed.
however, if you look(ed) at your sql server errorlog, you should find an entry saying that file growth was failing, taking too much time.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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