title: The transaction log for the database is full
body: <p>I have a long running process that holds open a transaction for the full duration. </p>
  
  <p>I have no control over the way this is executed. </p>
  
  <p>Because a transaction is held open for the full duration, when the transaction log fills, SQL Server cannot increase the size of the log file. </p>
  
  <p>So the process fails with the error <code>"The transaction log for database 'xxx' is full"</code>.</p>
  
  <p>I have attempted to prevent this by increasing the size of the transaction log file in the database properties, but I get the same error.</p>
  
  <p>Not sure what I should try next. The process runs for several hours so it's not easy to play trial and error. </p>
  
  <p>Any ideas?</p>
  
  <p>If anyone is interested, the process is an organisation import in <code>Microsoft Dynamics CRM 4.0.</code>  </p>
  
  <p>There is plenty of disk space, we have the log in simple logging mode and have backed up the log prior to kicking off the process.</p>
  
  <p>-=-=-=-=- UPDATE -=-=-=-=-</p>
  
  <p>Thanks all for the comments so far.  The following is what led me to believe that the log would not grow due to the open transaction:</p>
  
  <p>I am getting the following error...</p>
  
  <pre><code>Import Organization (Name=xxx, Id=560d04e7-98ed-e211-9759-0050569d6d39) failed with Exception:
  System.Data.SqlClient.SqlException: The transaction log for database 'xxx' is full. To find out why space in the log cannot be reused, see the log_reuse_wait_desc column in sys.databases
  </code></pre>
  
  <p>So following that advice I went to "<code>log_reuse_wait_desc column in sys.databases</code>" and it held the value "<code>ACTIVE_TRANSACTION</code>".</p>
  
  <p>According to Microsoft:
  <a href="http://msdn.microsoft.com/en-us/library/ms345414(v=sql.105).aspx">http://msdn.microsoft.com/en-us/library/ms345414(v=sql.105).aspx</a></p>
  
  <p>That means the following:</p>
  
  <p>A transaction is active (all recovery models).
  • A long-running transaction might exist at the start of the log backup. In this case, freeing the space might require another log backup. For more information, see "Long-Running Active Transactions," later in this topic.</p>
  
  <p>• A transaction is deferred (SQL Server 2005 Enterprise Edition and later versions only). A deferred transaction is effectively an active transaction whose rollback is blocked because of some unavailable resource. For information about the causes of deferred transactions and how to move them out of the deferred state, see Deferred Transactions. </p>
  
  <p>Have I misunderstood something?</p>
  
  <p>-=-=-=- UPDATE 2 -=-=-=-</p>
  
  <p>Just kicked off the process with initial log file size set to 30GB.  This will take a couple of hours to complete.</p>
  
  <p>-=-=-=- Final UPDATE -=-=-=-</p>
  
  <p>The issue was actually caused by the log file consuming all available disk space.  In the last attempt I freed up 120GB and it still used all of it and ultimately failed.</p>
  
  <p>I didn't realise this was happening previously because when the process was running overnight, it was rolling back on failure.  This time I was able to check the log file size before the rollback.</p>
  
  <p>Thanks all for your input.</p>