{"id":892,"date":"2009-04-21T00:42:00","date_gmt":"2009-04-21T00:42:00","guid":{"rendered":"\/blogs\/paul\/post\/Inside-the-Storage-Engine-More-on-the-circular-nature-of-the-log.aspx"},"modified":"2018-08-30T12:39:04","modified_gmt":"2018-08-30T19:39:04","slug":"inside-the-storage-engine-more-on-the-circular-nature-of-the-log","status":"publish","type":"post","link":"https:\/\/www.sqlskills.com\/blogs\/paul\/inside-the-storage-engine-more-on-the-circular-nature-of-the-log\/","title":{"rendered":"Inside the Storage Engine: More on the circular nature of the log"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p>Every so often (well, ok, very frequently) my internal list of &#8216;I must blog about that&#8217; gets too big and I have an almost uncontrollable urge. Luckily, these urges end up with me blogging several times, otherwise who knows what kind of trouble I&#8217;d get into? :-)<\/p>\n<p>First up today is some pretty deep\u00a0internals about how the transaction log works in a specific situation. This has come up a few times in the last few internals\/maintenance classes I&#8217;ve taught in the transaction log module so I wanted to get a blog post out there that proves my answer is correct. The question is easier to frame with a picture, borrowed from my TechNet Magazine article from February (see <a href=\"https:\/\/technet.microsoft.com\/en-us\/library\/2009.02.logging.aspx\">here<\/a>).<\/p>\n<p><img fetchpriority=\"high\" decoding=\"async\" src=\"\/blogs\/paul\/wp-content\/uploads\/2009\/4\/dd392031_fig03a(en-us).gif\" alt=\"\" width=\"500\" height=\"189\" \/><\/p>\n<p>The image shows the circular natue of the transaction log, and how VLFs can be overwritten once the log has wrapped around, as long as they are no longer active (red = active log\/VLF, blue = inactive log\/VLF). If none of this makes sense to you, go read the TechNet Magazine article and it should do.<\/p>\n<p>The question is: what happens if log records continue being written to VLFs 1 and 2 in the picture, and eventually the end of VLF 2 has been reached, but VLF 3 is still active, and can&#8217;t be overwritten? Does the database just stop?<\/p>\n<p>Let&#8217;s find out.<\/p>\n<p>I&#8217;m going to create a database and then engineer the situation above.<\/p>\n<blockquote><p>CREATE DATABASE LogTestDB ON PRIMARY (<br \/>\nNAME = LogTestDB_data,<br \/>\nFILENAME = N&#8217;C:\\SQLskills\\LogTestDB_data.mdf&#8217;)<br \/>\nLOG ON (<br \/>\nNAME = &#8216;LogTestDB_log&#8217;,<br \/>\nFILENAME = N&#8217;C:\\SQLskills\\LogTestDB_log.ldf&#8217;,<br \/>\nSIZE = 5MB);<br \/>\nGO<\/p><\/blockquote>\n<p>&nbsp;<\/p>\n<p><span style=\"font-family: verdana, geneva; font-size: small;\">The database is in the <span style=\"font-family: 'courier new', courier;\">SIMPLE<\/span> recovery model. Well, to\u00a0be completely honest, it&#8217;s in the <span style=\"font-family: 'courier new', courier;\">FULL<\/span> recovery model, but there hasn&#8217;t been a full database backup yet, so as far as transaction log behavior is concerned, it behaves as if it was in <span style=\"font-family: 'courier new', courier;\">SIMPLE <\/span>(the log can\u00a0be cleared\u00a0by a\u00a0<span style=\"font-family: 'courier new', courier;\">CHECKPOINT<\/span>)\u00a0&#8211; again, if this makes no sense, go read the TechNet Magazine article.\u00a0<\/span><\/p>\n<p><span style=\"font-family: verdana, geneva; font-size: small;\">And then see how many VLFs it has using the <span style=\"font-family: 'courier new', courier;\">DBCC LOGINFO<\/span> command (and this is the *only* way to see how many VLFs there are):<\/span><\/p>\n<blockquote><p><span style=\"font-family: 'courier new', courier; font-size: small;\">DBCC LOGINFO (&#8216;LogTestDB&#8217;);<br \/>\nGO <\/span><\/p>\n<p><span style=\"font-family: 'courier new', courier; font-size: small;\">FileId\u00a0\u00a0 FileSize\u00a0\u00a0 StartOffset\u00a0\u00a0 FSeqNo\u00a0\u00a0 Status\u00a0\u00a0 Parity CreateLSN<br \/>\n&#8212;&#8212;&#8211; &#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;&#8212;- &#8212;&#8212;&#8211; &#8212;&#8212;&#8211; &#8212;&#8212; &#8212;&#8212;&#8212;&#8211;<br \/>\n2\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1245184\u00a0\u00a0\u00a0 8192\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 31\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 2\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 64\u00a0\u00a0\u00a0\u00a0 0<br \/>\n2\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1245184\u00a0\u00a0\u00a0 1253376\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0\u00a0\u00a0 0<br \/>\n2\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1245184\u00a0\u00a0\u00a0 2498560\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0\u00a0\u00a0 0<br \/>\n2\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1499136\u00a0\u00a0\u00a0 3743744\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0\u00a0\u00a0 0<\/span><\/p><\/blockquote>\n<p><span style=\"font-family: verdana, geneva; font-size: small;\">We&#8217;ve got 4 VLFs. The <span style=\"font-family: 'courier new', courier;\">Status<\/span> column tells us whether the VLF is active or not. A status of 2 means the VLF is active, 0 means it&#8217;s not (Edit 8\/30\/18: a status of 4 is possible on an AG secondary where a VLF exists on the primary but the log file growth hasn&#8217;t been replayed on the secondary yet). The sequence number (<span style=\"font-family: 'courier new', courier;\">FSeqNo<\/span>) is the logical order of the VLFs within the log. The <span style=\"font-family: 'courier new', courier;\">FileSize<\/span> is in bytes (so each VLF is about 1.25 MB). Right now there&#8217;s only one active VLF.<\/span><\/p>\n<p><span style=\"font-family: verdana, geneva; font-size: small;\">Now I&#8217;ll engineer the situation in the image above. I&#8217;m going to fill the log so that VLFs 1, 2, and 3 are active. Then I&#8217;m going to start an explicit transaction that will hold VLF 3 and onwards active. Then I&#8217;ll continue filling the log so it wraps around and starts to fill up VLF 1 again.<\/span><\/p>\n<blockquote><p><span style=\"font-family: 'courier new', courier; font-size: small;\">USE LogTestDB;<br \/>\nGO<br \/>\nCREATE TABLE BigRows (c1 INT IDENTITY, c2 CHAR (8000) DEFAULT &#8216;a&#8217;);<br \/>\nGO <\/span><\/p>\n<p><span style=\"font-family: 'courier new', courier; font-size: small;\">SET NOCOUNT ON;<br \/>\nINSERT INTO BigRows DEFAULT VALUES;<br \/>\nGO 300<\/span><\/p><\/blockquote>\n<p><span style=\"font-family: verdana, geneva; font-size: small;\">I&#8217;ve filled up VLFs 1 and 2, and started on 3. Let&#8217;s check with <span style=\"font-family: 'courier new', courier;\">DBCC LOGINFO<\/span>:<\/span><\/p>\n<blockquote><p><span style=\"font-family: 'courier new', courier; font-size: small;\">DBCC LOGINFO (&#8216;LogTestDB&#8217;);<br \/>\nGO <\/span><\/p>\n<p><span style=\"font-family: 'courier new', courier; font-size: small;\">FileId\u00a0\u00a0 FileSize\u00a0\u00a0 StartOffset\u00a0\u00a0 FSeqNo\u00a0\u00a0 Status\u00a0\u00a0 Parity CreateLSN<br \/>\n&#8212;&#8212;&#8211; &#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;&#8212;- &#8212;&#8212;&#8211; &#8212;&#8212;&#8211; &#8212;&#8212; &#8212;&#8212;&#8212;&#8211;<br \/>\n2\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1245184\u00a0\u00a0\u00a0 8192\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 31\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 2\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 64\u00a0\u00a0\u00a0\u00a0 0<br \/>\n2\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1245184\u00a0\u00a0\u00a0 1253376\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 32\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 2\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 64\u00a0\u00a0\u00a0\u00a0 0<br \/>\n2\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1245184\u00a0\u00a0\u00a0 2498560\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 33\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 2\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 64\u00a0\u00a0\u00a0\u00a0 0<br \/>\n2\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1499136\u00a0\u00a0\u00a0 3743744\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0\u00a0\u00a0 0<\/span><\/p><\/blockquote>\n<p><span style=\"font-family: verdana, geneva; font-size: small;\">As you can see, the first 3 VLFs now have a status of 2 (active), and they&#8217;re in sequence. Now I&#8217;ll create an explicit transaction that will prevent VLF 3 and onwards being cleared.<\/span><\/p>\n<blockquote><p><span style=\"font-family: 'courier new', courier; font-size: small;\">BEGIN TRAN<br \/>\nINSERT INTO BigRows DEFAULT VALUES;<br \/>\nGO<\/span><\/p><\/blockquote>\n<p><span style=\"font-family: verdana, geneva; font-size: small;\">If I explicitly do a <span style=\"font-family: 'courier new', courier;\">CHECKPOINT<\/span> now, VLFs 1 and 2 will clear:<\/span><\/p>\n<blockquote><p><span style=\"font-family: 'courier new', courier; font-size: small;\">CHECKPOINT<br \/>\nGO <\/span><\/p>\n<p><span style=\"font-family: 'courier new', courier; font-size: small;\">DBCC LOGINFO (&#8216;LogTestDB&#8217;);<br \/>\nGO <\/span><\/p>\n<p><span style=\"font-family: 'courier new', courier; font-size: small;\">FileId\u00a0\u00a0 FileSize\u00a0\u00a0 StartOffset\u00a0\u00a0 FSeqNo\u00a0\u00a0 Status\u00a0\u00a0 Parity CreateLSN<br \/>\n&#8212;&#8212;&#8211; &#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;&#8212;- &#8212;&#8212;&#8211; &#8212;&#8212;&#8211; &#8212;&#8212; &#8212;&#8212;&#8212;-<br \/>\n2\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a01245184\u00a0\u00a0\u00a0\u00a08192\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a031\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a00\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a064\u00a0\u00a0\u00a0\u00a0 0<br \/>\n2\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a01245184\u00a0\u00a0\u00a0 1253376\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a032\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a00\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a064\u00a0\u00a0\u00a0\u00a0 0<br \/>\n2\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a01245184\u00a0\u00a0\u00a0 2498560\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a033\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a02\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a064\u00a0\u00a0\u00a0\u00a0 0<br \/>\n2\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a01499136\u00a0\u00a0\u00a0 3743744\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a00\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a00\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a00\u00a0\u00a0\u00a0\u00a0\u00a0 0<\/span><\/p><\/blockquote>\n<p><span style=\"font-family: verdana, geneva; font-size: small;\">Now I&#8217;ll carry on filling up the BigRows table so the log wraps around and starts filling up VLFs 1 and two again.<\/span><\/p>\n<blockquote><p><span style=\"font-family: 'courier new', courier; font-size: small;\">INSERT INTO BigRows DEFAULT VALUES;<br \/>\nGO 300 <\/span><\/p>\n<p><span style=\"font-family: 'courier new', courier; font-size: small;\">DBCC LOGINFO (&#8216;LogTestDB&#8217;);<br \/>\nGO<\/span><\/p>\n<p><span style=\"font-family: 'courier new', courier; font-size: small;\">FileId\u00a0\u00a0 FileSize\u00a0\u00a0 StartOffset\u00a0\u00a0 FSeqNo\u00a0\u00a0 Status\u00a0\u00a0 Parity CreateLSN<br \/>\n&#8212;&#8212;&#8211; &#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;&#8212;- &#8212;&#8212;&#8211; &#8212;&#8212;&#8211; &#8212;&#8212; &#8212;&#8212;&#8212;-<br \/>\n2\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a01245184\u00a0\u00a0\u00a0\u00a08192\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a035\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a02\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0128\u00a0\u00a0\u00a0 0<br \/>\n2\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a01245184\u00a0\u00a0\u00a0\u00a01253376\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a032\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a00\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a064\u00a0\u00a0\u00a0\u00a0 0<br \/>\n2\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a01245184\u00a0\u00a0\u00a0\u00a02498560\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 33\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a02\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a064\u00a0\u00a0\u00a0\u00a0 0<br \/>\n2\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a01499136\u00a0\u00a0\u00a0\u00a03743744\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a034\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a02\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a064\u00a0\u00a0\u00a0\u00a0 0<br \/>\n<\/span><\/p><\/blockquote>\n<p><span style=\"font-family: verdana, geneva; font-size: small;\">You can see that the log has wrapped around now, but VLFs 3 and 4 are still active. Look at the sequence numbers of the active VLFs&#8230; the active log is VLF 3 then 4 then 1, with sequence numbers 33 then 34 then 35. Now if I carry on filling up the table, what&#8217;s going to happen when the log bumps up against VLF 3 that is still active? Will it stop or will it grow?<\/span><\/p>\n<blockquote><p><span style=\"font-family: 'courier new', courier; font-size: small;\">INSERT INTO BigRows DEFAULT VALUES;<br \/>\nGO 300 <\/span><\/p>\n<p><span style=\"font-family: 'courier new', courier; font-size: small;\">DBCC LOGINFO (&#8216;LogTestDB&#8217;);<br \/>\nGO<\/span><\/p>\n<p><span style=\"font-family: 'courier new', courier; font-size: small;\">FileId\u00a0\u00a0 FileSize\u00a0\u00a0 StartOffset\u00a0\u00a0 FSeqNo\u00a0\u00a0 Status\u00a0\u00a0 Parity CreateLSN<br \/>\n&#8212;&#8212;&#8211; &#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;&#8212;- &#8212;&#8212;&#8211; &#8212;&#8212;&#8211; &#8212;&#8212; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\n<\/span><span style=\"font-family: 'courier new', courier; font-size: small;\">2\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a01245184\u00a0\u00a0\u00a0\u00a08192\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a035\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a02\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0128\u00a0\u00a0\u00a0 0<br \/>\n2\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a01245184\u00a0\u00a0\u00a0\u00a01253376\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a036\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a02\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0128\u00a0\u00a0\u00a0 0<br \/>\n2\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a01245184\u00a0\u00a0\u00a0\u00a02498560\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a033\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a02\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a064\u00a0\u00a0\u00a0\u00a0 0<br \/>\n2\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a01499136\u00a0\u00a0\u00a0\u00a03743744\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a034\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a02\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a064\u00a0\u00a0\u00a0\u00a0 0<br \/>\n2\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0253952\u00a0\u00a0\u00a0\u00a0\u00a05242880\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a037\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a02\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 64\u00a0\u00a0\u00a0\u00a0 36000000049300052<br \/>\n2\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 270336\u00a0\u00a0\u00a0\u00a0\u00a05496832\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a038\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a02\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a064\u00a0\u00a0\u00a0\u00a0 36000000049300052<br \/>\n2\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0253952\u00a0\u00a0\u00a0\u00a0\u00a05767168\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a00\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a00\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a00\u00a0\u00a0\u00a0\u00a0\u00a0 36000000107500066<br \/>\n2\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0335872\u00a0\u00a0\u00a0\u00a0\u00a06021120\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a00\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a00\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a00\u00a0\u00a0\u00a0\u00a0\u00a0 36000000107500066<br \/>\n2\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0253952\u00a0\u00a0\u00a0\u00a0\u00a06356992\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a00\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a00\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a00\u00a0\u00a0\u00a0\u00a0\u00a0 36000000190700020<br \/>\n2\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0401408\u00a0\u00a0\u00a0\u00a0\u00a06610944\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a00\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a00\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a00\u00a0\u00a0\u00a0\u00a0\u00a0 36000000190700020<br \/>\n2\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0253952\u00a0\u00a0\u00a0\u00a0\u00a07012352\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a00\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a00\u00a0\u00a0\u00a0\u00a0\u00a0 37000000037300040<br \/>\n2\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0466944\u00a0\u00a0\u00a0\u00a0\u00a07266304\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a00\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a00\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a00\u00a0\u00a0\u00a0\u00a0\u00a0 37000000037300040<\/span><\/p><\/blockquote>\n<p><span style=\"font-family: verdana, geneva; font-size: small;\">The answer is that it grew, and kind of skipped the active VLFs! Look at the sequence numbers. The new sequence of the active log is VLF 3 then 4 then 1 then 2 then 5 then 6, as you can see from the sequence numbers. Once the active transaction I created commits or rolls back, VLFs 3, 4, 1, and 2 can clear and then the &#8216;normal&#8217; sequencing of VLFs in the log will resume.<\/span><\/p>\n<p><span style=\"font-family: verdana, geneva; font-size: small;\">Every VLF has a small header which contains the sequence number of the VLF within the transaction log, so the log can kind of do contortions to work around active VLFs in the middle of the log. Very cool.<\/span><\/p>\n<p><span style=\"font-family: verdana, geneva; font-size: small;\">Ok &#8211; that was fun &#8211; now I feel better!<\/span><\/p>\n<p><span style=\"font-size: small;\">PS In the last couple of <span style=\"font-family: 'courier new', courier;\">DBCC LOGINFO<\/span> dumps, where the log has wrapped around, you can see that the parity bits for the log blocks in the VLFs have\u00a0changed, as I explained in one of my previous posts <a href=\"https:\/\/www.sqlskills.com\/blogs\/paul\/search-engine-qa-24-why-cant-the-transaction-log-use-instant-initialization\/\">Search Engine Q&amp;A #24: Why can&#8217;t the transaction log use instant initialization?<\/a>.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Every so often (well, ok, very frequently) my internal list of &#8216;I must blog about that&#8217; gets too big and I have an almost uncontrollable urge. Luckily, these urges end up with me blogging several times, otherwise who knows what kind of trouble I&#8217;d get into? :-) First up today is some pretty deep\u00a0internals [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[31,48,62,98],"tags":[],"class_list":["post-892","post","type-post","status-publish","format-standard","hentry","category-database-maintenance","category-inside-the-storage-engine","category-on-disk-structures","category-transaction-log"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Inside the Storage Engine: More on the circular nature of the log - Paul S. Randal<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.sqlskills.com\/blogs\/paul\/inside-the-storage-engine-more-on-the-circular-nature-of-the-log\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Inside the Storage Engine: More on the circular nature of the log - Paul S. Randal\" \/>\n<meta property=\"og:description\" content=\"&nbsp; Every so often (well, ok, very frequently) my internal list of &#8216;I must blog about that&#8217; gets too big and I have an almost uncontrollable urge. Luckily, these urges end up with me blogging several times, otherwise who knows what kind of trouble I&#8217;d get into? :-) First up today is some pretty deep\u00a0internals [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlskills.com\/blogs\/paul\/inside-the-storage-engine-more-on-the-circular-nature-of-the-log\/\" \/>\n<meta property=\"og:site_name\" content=\"Paul S. Randal\" \/>\n<meta property=\"article:published_time\" content=\"2009-04-21T00:42:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-08-30T19:39:04+00:00\" \/>\n<meta name=\"author\" content=\"Paul Randal\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Paul Randal\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/inside-the-storage-engine-more-on-the-circular-nature-of-the-log\/\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/inside-the-storage-engine-more-on-the-circular-nature-of-the-log\/\",\"name\":\"Inside the Storage Engine: More on the circular nature of the log - Paul S. Randal\",\"isPartOf\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#website\"},\"datePublished\":\"2009-04-21T00:42:00+00:00\",\"dateModified\":\"2018-08-30T19:39:04+00:00\",\"author\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/inside-the-storage-engine-more-on-the-circular-nature-of-the-log\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.sqlskills.com\/blogs\/paul\/inside-the-storage-engine-more-on-the-circular-nature-of-the-log\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/inside-the-storage-engine-more-on-the-circular-nature-of-the-log\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Inside the Storage Engine: More on the circular nature of the log\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#website\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/\",\"name\":\"Paul S. Randal\",\"description\":\"In Recovery...\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce\",\"name\":\"Paul Randal\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/0b6a266bba2f088f2551ef529293001bd73bf026bc1908b9866728c062beeeb6?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/0b6a266bba2f088f2551ef529293001bd73bf026bc1908b9866728c062beeeb6?s=96&d=mm&r=g\",\"caption\":\"Paul Randal\"},\"sameAs\":[\"http:\/\/3.209.169.194\/blogs\/paul\"],\"url\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/author\/paul\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Inside the Storage Engine: More on the circular nature of the log - Paul S. Randal","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.sqlskills.com\/blogs\/paul\/inside-the-storage-engine-more-on-the-circular-nature-of-the-log\/","og_locale":"en_US","og_type":"article","og_title":"Inside the Storage Engine: More on the circular nature of the log - Paul S. Randal","og_description":"&nbsp; Every so often (well, ok, very frequently) my internal list of &#8216;I must blog about that&#8217; gets too big and I have an almost uncontrollable urge. Luckily, these urges end up with me blogging several times, otherwise who knows what kind of trouble I&#8217;d get into? :-) First up today is some pretty deep\u00a0internals [&hellip;]","og_url":"https:\/\/www.sqlskills.com\/blogs\/paul\/inside-the-storage-engine-more-on-the-circular-nature-of-the-log\/","og_site_name":"Paul S. Randal","article_published_time":"2009-04-21T00:42:00+00:00","article_modified_time":"2018-08-30T19:39:04+00:00","author":"Paul Randal","twitter_misc":{"Written by":"Paul Randal","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/inside-the-storage-engine-more-on-the-circular-nature-of-the-log\/","url":"https:\/\/www.sqlskills.com\/blogs\/paul\/inside-the-storage-engine-more-on-the-circular-nature-of-the-log\/","name":"Inside the Storage Engine: More on the circular nature of the log - Paul S. Randal","isPartOf":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#website"},"datePublished":"2009-04-21T00:42:00+00:00","dateModified":"2018-08-30T19:39:04+00:00","author":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce"},"breadcrumb":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/inside-the-storage-engine-more-on-the-circular-nature-of-the-log\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlskills.com\/blogs\/paul\/inside-the-storage-engine-more-on-the-circular-nature-of-the-log\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/inside-the-storage-engine-more-on-the-circular-nature-of-the-log\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlskills.com\/blogs\/paul\/"},{"@type":"ListItem","position":2,"name":"Inside the Storage Engine: More on the circular nature of the log"}]},{"@type":"WebSite","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#website","url":"https:\/\/www.sqlskills.com\/blogs\/paul\/","name":"Paul S. Randal","description":"In Recovery...","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sqlskills.com\/blogs\/paul\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce","name":"Paul Randal","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/0b6a266bba2f088f2551ef529293001bd73bf026bc1908b9866728c062beeeb6?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/0b6a266bba2f088f2551ef529293001bd73bf026bc1908b9866728c062beeeb6?s=96&d=mm&r=g","caption":"Paul Randal"},"sameAs":["http:\/\/3.209.169.194\/blogs\/paul"],"url":"https:\/\/www.sqlskills.com\/blogs\/paul\/author\/paul\/"}]}},"_links":{"self":[{"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/posts\/892","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/comments?post=892"}],"version-history":[{"count":0,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/posts\/892\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/media?parent=892"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/categories?post=892"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/tags?post=892"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}