title: Question about database transaction log
body: <p>I read the following statement:</p>
  
  <blockquote>
    <p>SQL Server doesn’t write data immediately to disk. It is kept in a
    buffer cache until this cache is full or until SQL Server issues a
    checkpoint, and then the data is written out. If a power failure
    occurs while the cache is still filling up, then that data is lost.
    Once the power comes back, though, SQL Server would start from its
    last checkpoint state, and any updates after the last checkpoint that
    were logged as successful transactions will be performed from the
    transaction log.</p>
  </blockquote>
  
  <p>And a couple of questions arise:</p>
  
  <ol>
  <li><p>What if the power failure happens <strong>after</strong> SQL Server issues a
  checkpoint and <strong>before</strong> the buffer cache is actuall written to
  disk? Isn't the content in buffer cache permanently missing?</p></li>
  <li><p>The transaction log is also stored as disk file, which is no
  different from the actual database file. So how could we guarantee
  the integrity of log file?</p></li>
  </ol>
  
  <p>So, is it true that no real transaction ever exists? It's only a matter of <strong>probability</strong>.</p>