You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by jt...@apache.org on 2005/02/04 02:50:25 UTC
svn commit: r151286 - in incubator/derby/site/trunk: build/site/
build/site/papers/ src/documentation/content/xdocs/
src/documentation/content/xdocs/papers/
Author: jta
Date: Thu Feb 3 17:50:21 2005
New Revision: 151286
URL: http://svn.apache.org/viewcvs?view=rev&rev=151286
Log:
Commited new papers/recovery doc by Dibyendu Majumdar <di...@mazumdar.demon.co.uk>.
Added:
incubator/derby/site/trunk/build/site/papers/recovery.html
incubator/derby/site/trunk/src/documentation/content/xdocs/papers/recovery.xml
Modified:
incubator/derby/site/trunk/build/site/linkmap.html
incubator/derby/site/trunk/build/site/papers/ApacheConUs04.html
incubator/derby/site/trunk/build/site/papers/JDBCImplementation.html
incubator/derby/site/trunk/build/site/papers/MiscPresentations.html
incubator/derby/site/trunk/build/site/papers/derby_arch.html
incubator/derby/site/trunk/build/site/papers/derby_htw.html
incubator/derby/site/trunk/build/site/papers/derby_plugin.html
incubator/derby/site/trunk/build/site/papers/derby_web.html
incubator/derby/site/trunk/build/site/papers/fortune_tut.html
incubator/derby/site/trunk/build/site/papers/index.html
incubator/derby/site/trunk/build/site/papers/logformats.html
incubator/derby/site/trunk/build/site/papers/misc.html
incubator/derby/site/trunk/build/site/papers/pageformats.html
incubator/derby/site/trunk/src/documentation/content/xdocs/papers/index.xml
incubator/derby/site/trunk/src/documentation/content/xdocs/site.xml
Modified: incubator/derby/site/trunk/build/site/linkmap.html
URL: http://svn.apache.org/viewcvs/incubator/derby/site/trunk/build/site/linkmap.html?view=diff&r1=151285&r2=151286
==============================================================================
--- incubator/derby/site/trunk/build/site/linkmap.html (original)
+++ incubator/derby/site/trunk/build/site/linkmap.html Thu Feb 3 17:50:21 2005
@@ -167,6 +167,9 @@
<div class="menuitem">
<a title="" href="papers/logformats.html">Log Format</a>
</div>
+<div class="menuitem">
+<a title="" href="papers/recovery.html">Logging & Recovery</a>
+</div>
</div>
<div onclick="SwitchMenu('menu_1.5', 'skin/')" id="menu_1.5Title" class="menutitle">Integration</div>
<div id="menu_1.5" class="menuitemgroup">
@@ -401,6 +404,10 @@
<li>
<a href="papers/logformats.html">Log Format</a> _________________________ <em>log</em>
+</li>
+
+<li>
+<a href="papers/recovery.html">Logging & Recovery</a> _________________________ <em>recover</em>
</li>
</ul>
Modified: incubator/derby/site/trunk/build/site/papers/ApacheConUs04.html
URL: http://svn.apache.org/viewcvs/incubator/derby/site/trunk/build/site/papers/ApacheConUs04.html?view=diff&r1=151285&r2=151286
==============================================================================
--- incubator/derby/site/trunk/build/site/papers/ApacheConUs04.html (original)
+++ incubator/derby/site/trunk/build/site/papers/ApacheConUs04.html Thu Feb 3 17:50:21 2005
@@ -128,6 +128,9 @@
<div class="menuitem">
<a title="" href="../papers/logformats.html">Log Format</a>
</div>
+<div class="menuitem">
+<a title="" href="../papers/recovery.html">Logging & Recovery</a>
+</div>
</div>
<div onclick="SwitchMenu('menu_1.3', '../skin/')" id="menu_1.3Title" class="menutitle">Integration</div>
<div id="menu_1.3" class="menuitemgroup">
Modified: incubator/derby/site/trunk/build/site/papers/JDBCImplementation.html
URL: http://svn.apache.org/viewcvs/incubator/derby/site/trunk/build/site/papers/JDBCImplementation.html?view=diff&r1=151285&r2=151286
==============================================================================
--- incubator/derby/site/trunk/build/site/papers/JDBCImplementation.html (original)
+++ incubator/derby/site/trunk/build/site/papers/JDBCImplementation.html Thu Feb 3 17:50:21 2005
@@ -128,6 +128,9 @@
<div class="menuitem">
<a title="" href="../papers/logformats.html">Log Format</a>
</div>
+<div class="menuitem">
+<a title="" href="../papers/recovery.html">Logging & Recovery</a>
+</div>
</div>
<div onclick="SwitchMenu('menu_1.3', '../skin/')" id="menu_1.3Title" class="menutitle">Integration</div>
<div id="menu_1.3" class="menuitemgroup">
Modified: incubator/derby/site/trunk/build/site/papers/MiscPresentations.html
URL: http://svn.apache.org/viewcvs/incubator/derby/site/trunk/build/site/papers/MiscPresentations.html?view=diff&r1=151285&r2=151286
==============================================================================
--- incubator/derby/site/trunk/build/site/papers/MiscPresentations.html (original)
+++ incubator/derby/site/trunk/build/site/papers/MiscPresentations.html Thu Feb 3 17:50:21 2005
@@ -128,6 +128,9 @@
<div class="menuitem">
<a title="" href="../papers/logformats.html">Log Format</a>
</div>
+<div class="menuitem">
+<a title="" href="../papers/recovery.html">Logging & Recovery</a>
+</div>
</div>
<div onclick="SwitchMenu('menu_1.3', '../skin/')" id="menu_1.3Title" class="menutitle">Integration</div>
<div id="menu_1.3" class="menuitemgroup">
Modified: incubator/derby/site/trunk/build/site/papers/derby_arch.html
URL: http://svn.apache.org/viewcvs/incubator/derby/site/trunk/build/site/papers/derby_arch.html?view=diff&r1=151285&r2=151286
==============================================================================
--- incubator/derby/site/trunk/build/site/papers/derby_arch.html (original)
+++ incubator/derby/site/trunk/build/site/papers/derby_arch.html Thu Feb 3 17:50:21 2005
@@ -128,6 +128,9 @@
<div class="menuitem">
<a title="" href="../papers/logformats.html">Log Format</a>
</div>
+<div class="menuitem">
+<a title="" href="../papers/recovery.html">Logging & Recovery</a>
+</div>
</div>
<div onclick="SwitchMenu('menu_1.3', '../skin/')" id="menu_1.3Title" class="menutitle">Integration</div>
<div id="menu_1.3" class="menuitemgroup">
Modified: incubator/derby/site/trunk/build/site/papers/derby_htw.html
URL: http://svn.apache.org/viewcvs/incubator/derby/site/trunk/build/site/papers/derby_htw.html?view=diff&r1=151285&r2=151286
==============================================================================
--- incubator/derby/site/trunk/build/site/papers/derby_htw.html (original)
+++ incubator/derby/site/trunk/build/site/papers/derby_htw.html Thu Feb 3 17:50:21 2005
@@ -128,6 +128,9 @@
<div class="menuitem">
<a title="" href="../papers/logformats.html">Log Format</a>
</div>
+<div class="menuitem">
+<a title="" href="../papers/recovery.html">Logging & Recovery</a>
+</div>
</div>
<div onclick="SwitchMenu('menu_1.3', '../skin/')" id="menu_1.3Title" class="menutitle">Integration</div>
<div id="menu_1.3" class="menuitemgroup">
Modified: incubator/derby/site/trunk/build/site/papers/derby_plugin.html
URL: http://svn.apache.org/viewcvs/incubator/derby/site/trunk/build/site/papers/derby_plugin.html?view=diff&r1=151285&r2=151286
==============================================================================
--- incubator/derby/site/trunk/build/site/papers/derby_plugin.html (original)
+++ incubator/derby/site/trunk/build/site/papers/derby_plugin.html Thu Feb 3 17:50:21 2005
@@ -128,6 +128,9 @@
<div class="menuitem">
<a title="" href="../papers/logformats.html">Log Format</a>
</div>
+<div class="menuitem">
+<a title="" href="../papers/recovery.html">Logging & Recovery</a>
+</div>
</div>
<div onclick="SwitchMenu('menu_selected_1.3', '../skin/')" id="menu_selected_1.3Title" class="menutitle" style="background-image: url('../skin/images/chapter_open.gif');">Integration</div>
<div id="menu_selected_1.3" class="selectedmenuitemgroup" style="display: block;">
Modified: incubator/derby/site/trunk/build/site/papers/derby_web.html
URL: http://svn.apache.org/viewcvs/incubator/derby/site/trunk/build/site/papers/derby_web.html?view=diff&r1=151285&r2=151286
==============================================================================
--- incubator/derby/site/trunk/build/site/papers/derby_web.html (original)
+++ incubator/derby/site/trunk/build/site/papers/derby_web.html Thu Feb 3 17:50:21 2005
@@ -128,6 +128,9 @@
<div class="menuitem">
<a title="" href="../papers/logformats.html">Log Format</a>
</div>
+<div class="menuitem">
+<a title="" href="../papers/recovery.html">Logging & Recovery</a>
+</div>
</div>
<div onclick="SwitchMenu('menu_1.3', '../skin/')" id="menu_1.3Title" class="menutitle">Integration</div>
<div id="menu_1.3" class="menuitemgroup">
Modified: incubator/derby/site/trunk/build/site/papers/fortune_tut.html
URL: http://svn.apache.org/viewcvs/incubator/derby/site/trunk/build/site/papers/fortune_tut.html?view=diff&r1=151285&r2=151286
==============================================================================
--- incubator/derby/site/trunk/build/site/papers/fortune_tut.html (original)
+++ incubator/derby/site/trunk/build/site/papers/fortune_tut.html Thu Feb 3 17:50:21 2005
@@ -128,6 +128,9 @@
<div class="menuitem">
<a title="" href="../papers/logformats.html">Log Format</a>
</div>
+<div class="menuitem">
+<a title="" href="../papers/recovery.html">Logging & Recovery</a>
+</div>
</div>
<div onclick="SwitchMenu('menu_1.3', '../skin/')" id="menu_1.3Title" class="menutitle">Integration</div>
<div id="menu_1.3" class="menuitemgroup">
Modified: incubator/derby/site/trunk/build/site/papers/index.html
URL: http://svn.apache.org/viewcvs/incubator/derby/site/trunk/build/site/papers/index.html?view=diff&r1=151285&r2=151286
==============================================================================
--- incubator/derby/site/trunk/build/site/papers/index.html (original)
+++ incubator/derby/site/trunk/build/site/papers/index.html Thu Feb 3 17:50:21 2005
@@ -128,6 +128,9 @@
<div class="menuitem">
<a title="" href="../papers/logformats.html">Log Format</a>
</div>
+<div class="menuitem">
+<a title="" href="../papers/recovery.html">Logging & Recovery</a>
+</div>
</div>
<div onclick="SwitchMenu('menu_1.3', '../skin/')" id="menu_1.3Title" class="menutitle">Integration</div>
<div id="menu_1.3" class="menuitemgroup">
@@ -237,12 +240,15 @@
<li>Log Format: <a href="logformats.html">Derby Write Ahead Log Format</a>
</li>
+
+<li>Logging & Recovery: <a href="recovery.html">Derby Logging and Recovery</a>
+</li>
</ul>
</div>
-<a name="N1003A"></a><a name="Integration"></a>
+<a name="N10040"></a><a name="Integration"></a>
<h2 class="boxed">Integration</h2>
<div class="section">
<p> The <a href="misc.html">Summary</a> contains pointers
@@ -274,7 +280,7 @@
</div>
-<a name="N10071"></a><a name="Presentations"></a>
+<a name="N10077"></a><a name="Presentations"></a>
<h2 class="boxed">Presentations</h2>
<div class="section">
<ul>
@@ -333,7 +339,7 @@
</div>
-<a name="N100D7"></a><a name="How+To%27s"></a>
+<a name="N100DD"></a><a name="How+To%27s"></a>
<h2 class="boxed">How To's</h2>
<div class="section">
<p>
@@ -345,7 +351,7 @@
</div>
-<a name="N100E5"></a><a name="How+to+Contribute+Papers"></a>
+<a name="N100EB"></a><a name="How+to+Contribute+Papers"></a>
<h2 class="boxed">How to Contribute Papers</h2>
<div class="section">
<p>
@@ -418,7 +424,7 @@
<p>
-<em>Last Updated: January 31, 2005</em>
+<em>Last Updated: February 3, 2005</em>
</p>
</div>
Modified: incubator/derby/site/trunk/build/site/papers/logformats.html
URL: http://svn.apache.org/viewcvs/incubator/derby/site/trunk/build/site/papers/logformats.html?view=diff&r1=151285&r2=151286
==============================================================================
--- incubator/derby/site/trunk/build/site/papers/logformats.html (original)
+++ incubator/derby/site/trunk/build/site/papers/logformats.html Thu Feb 3 17:50:21 2005
@@ -128,6 +128,9 @@
<div class="menupage">
<div class="menupagetitle">Log Format</div>
</div>
+<div class="menuitem">
+<a title="" href="../papers/recovery.html">Logging & Recovery</a>
+</div>
</div>
<div onclick="SwitchMenu('menu_1.3', '../skin/')" id="menu_1.3Title" class="menutitle">Integration</div>
<div id="menu_1.3" class="menuitemgroup">
Modified: incubator/derby/site/trunk/build/site/papers/misc.html
URL: http://svn.apache.org/viewcvs/incubator/derby/site/trunk/build/site/papers/misc.html?view=diff&r1=151285&r2=151286
==============================================================================
--- incubator/derby/site/trunk/build/site/papers/misc.html (original)
+++ incubator/derby/site/trunk/build/site/papers/misc.html Thu Feb 3 17:50:21 2005
@@ -128,6 +128,9 @@
<div class="menuitem">
<a title="" href="../papers/logformats.html">Log Format</a>
</div>
+<div class="menuitem">
+<a title="" href="../papers/recovery.html">Logging & Recovery</a>
+</div>
</div>
<div onclick="SwitchMenu('menu_selected_1.3', '../skin/')" id="menu_selected_1.3Title" class="menutitle" style="background-image: url('../skin/images/chapter_open.gif');">Integration</div>
<div id="menu_selected_1.3" class="selectedmenuitemgroup" style="display: block;">
Modified: incubator/derby/site/trunk/build/site/papers/pageformats.html
URL: http://svn.apache.org/viewcvs/incubator/derby/site/trunk/build/site/papers/pageformats.html?view=diff&r1=151285&r2=151286
==============================================================================
--- incubator/derby/site/trunk/build/site/papers/pageformats.html (original)
+++ incubator/derby/site/trunk/build/site/papers/pageformats.html Thu Feb 3 17:50:21 2005
@@ -128,6 +128,9 @@
<div class="menuitem">
<a title="" href="../papers/logformats.html">Log Format</a>
</div>
+<div class="menuitem">
+<a title="" href="../papers/recovery.html">Logging & Recovery</a>
+</div>
</div>
<div onclick="SwitchMenu('menu_1.3', '../skin/')" id="menu_1.3Title" class="menutitle">Integration</div>
<div id="menu_1.3" class="menuitemgroup">
Added: incubator/derby/site/trunk/build/site/papers/recovery.html
URL: http://svn.apache.org/viewcvs/incubator/derby/site/trunk/build/site/papers/recovery.html?view=auto&rev=151286
==============================================================================
--- incubator/derby/site/trunk/build/site/papers/recovery.html (added)
+++ incubator/derby/site/trunk/build/site/papers/recovery.html Thu Feb 3 17:50:21 2005
@@ -0,0 +1,596 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<meta content="Apache Forrest" name="Generator">
+<meta name="Forrest-version" content="0.6">
+<meta name="Forrest-skin-name" content="pelt">
+<title>Derby Logging and Recovery</title>
+<link type="text/css" href="../skin/basic.css" rel="stylesheet">
+<link media="screen" type="text/css" href="../skin/screen.css" rel="stylesheet">
+<link media="print" type="text/css" href="../skin/print.css" rel="stylesheet">
+<link type="text/css" href="../skin/profile.css" rel="stylesheet">
+<script src="../skin/getBlank.js" language="javascript" type="text/javascript"></script><script src="../skin/getMenu.js" language="javascript" type="text/javascript"></script><script src="../skin/fontsize.js" language="javascript" type="text/javascript"></script>
+<link rel="shortcut icon" href="../">
+</head>
+<body onload="init()">
+<script type="text/javascript">ndeSetTextSize();</script>
+<div id="top">
+<!--+
+ |breadtrail
+ +-->
+<div class="breadtrail">
+<a href="http://www.apache.org/">apache</a> > <a href="http://incubator.apache.org/">incubator</a><script src="../skin/breadcrumbs.js" language="JavaScript" type="text/javascript"></script>
+</div>
+<!--+
+ |header
+ +-->
+<div class="header">
+<!--+
+ |start group logo
+ +-->
+<div class="grouplogo">
+<a href="http://incubator.apache.org"><img class="logoImage" alt="" src="../images/apache-incubator-logo.png" title=""></a>
+</div>
+<!--+
+ |end group logo
+ +-->
+<!--+
+ |start Project Logo
+ +-->
+<div class="projectlogo">
+<a href="http://incubator.apache.org/derby/"><img class="logoImage" alt="Derby" src="../images/derby-logo.jpg" title="Derby is a zero admin java RDBMS."></a>
+</div>
+<!--+
+ |end Project Logo
+ +-->
+<!--+
+ |start Search
+ +-->
+<div class="searchbox">
+<form action="http://www.google.com/search" method="get" class="roundtopsmall">
+<input value="apache.org" name="sitesearch" type="hidden"><input onFocus="getBlank (this, 'Search the site with google:');" value="Search the site with google:" size="25" name="q" id="query" type="text">
+ <input name="Search" value="Search" type="submit">
+</form>
+</div>
+<!--+
+ |end search
+ +-->
+<!--+
+ |start Tabs
+ +-->
+<ul id="tabs">
+<li>
+<a class="base-not-selected" href="../index.html">Home</a>
+</li>
+<li>
+<a class="base-not-selected" href="../manuals/index.html">Manuals</a>
+</li>
+<li class="current">
+<a class="base-selected" href="../papers/index.html">Papers</a>
+</li>
+</ul>
+<!--+
+ |end Tabs
+ +-->
+</div>
+</div>
+<div id="main">
+<div id="publishedStrip">
+<!--+
+ |start Subtabs
+ +-->
+<div id="level2tabs"></div>
+<!--+
+ |end Endtabs
+ +-->
+<script type="text/javascript" language="JavaScript"><!--
+ document.write("Published: " + document.lastModified);
+ // --></script>
+</div>
+<!--+
+ |breadtrail
+ +-->
+<div class="breadtrail">
+
+
+ </div>
+<!--+
+ |start Menu, mainarea
+ +-->
+<!--+
+ |start Menu
+ +-->
+<div id="menu">
+<div onclick="SwitchMenu('menu_1.1', '../skin/')" id="menu_1.1Title" class="menutitle">About</div>
+<div id="menu_1.1" class="menuitemgroup">
+<div class="menuitem">
+<a title="" href="../papers/index.html">Index</a>
+</div>
+<div class="menuitem">
+<a title="" href="../papers/derby_web.html">Derby Web Site</a>
+</div>
+</div>
+<div onclick="SwitchMenu('menu_selected_1.2', '../skin/')" id="menu_selected_1.2Title" class="menutitle" style="background-image: url('../skin/images/chapter_open.gif');">Derby Engine</div>
+<div id="menu_selected_1.2" class="selectedmenuitemgroup" style="display: block;">
+<div class="menuitem">
+<a title="" href="../papers/derby_arch.html">Architecture</a>
+</div>
+<div class="menuitem">
+<a title="" href="../papers/pageformats.html">Disk Page Format</a>
+</div>
+<div class="menuitem">
+<a title="" href="../papers/derby_htw.html">How Things Work</a>
+</div>
+<div class="menuitem">
+<a title="" href="../papers/JDBCImplementation.html">JDBC</a>
+</div>
+<div class="menuitem">
+<a title="" href="../papers/logformats.html">Log Format</a>
+</div>
+<div class="menupage">
+<div class="menupagetitle">Logging & Recovery</div>
+</div>
+</div>
+<div onclick="SwitchMenu('menu_1.3', '../skin/')" id="menu_1.3Title" class="menutitle">Integration</div>
+<div id="menu_1.3" class="menuitemgroup">
+<div class="menuitem">
+<a title="" href="../papers/misc.html">Summary</a>
+</div>
+<div class="menuitem">
+<a title="" href="../binaries/HOWTO_CJDBC_Derby_v0.2.pdf">C-JDBC (PDF)</a>
+</div>
+<div class="menuitem">
+<a title="" href="../binaries/HOWTO_CJDBC_Derby_v0.2.sxw">C-JDBC (SXW)</a>
+</div>
+<div class="menuitem">
+<a title="" href="../DOTS_Derby.html">DOTS</a>
+</div>
+<div class="menuitem">
+<a title="" href="../papers/derby_plugin.html">Eclipse</a>
+</div>
+<div class="menuitem">
+<a title="" href="../binaries/DerbyAndRedHatAppServer.pdf">JOnAS (PDF)</a>
+</div>
+</div>
+<div onclick="SwitchMenu('menu_1.4', '../skin/')" id="menu_1.4Title" class="menutitle">Presentations</div>
+<div id="menu_1.4" class="menuitemgroup">
+<div class="menuitem">
+<a title="" href="../papers/MiscPresentations.html">Colorado 2004</a>
+</div>
+<div class="menuitem">
+<a title="" href="../papers/ApacheConUs04.html">ApacheCon US '04</a>
+</div>
+</div>
+<div onclick="SwitchMenu('menu_1.5', '../skin/')" id="menu_1.5Title" class="menutitle">How To's</div>
+<div id="menu_1.5" class="menuitemgroup">
+<div class="menuitem">
+<a title="" href="../papers/fortune_tut.html">Embedded Tutorial</a>
+</div>
+</div>
+<div id="credit"></div>
+<div id="roundbottom">
+<img style="display: none" class="corner" height="15" width="15" alt="" src="../skin/images/rc-b-l-15-1body-2menu-3menu.png"></div>
+<!--+
+ |alternative credits
+ +-->
+</div>
+<!--+
+ |end Menu
+ +-->
+<!--+
+ |start content
+ +-->
+<div id="content">
+<div id="skinconf-txtlink"></div>
+<div class="trail">
+ Font size:
+ <input value="Reset" class="resetfont" title="Reset text" onclick="ndeSetTextSize('reset'); return false;" type="button">
+ <input value="-a" class="smallerfont" title="Shrink text" onclick="ndeSetTextSize('decr'); return false;" type="button">
+ <input value="+a" class="biggerfont" title="Enlarge text" onclick="ndeSetTextSize('incr'); return false;" type="button">
+</div>
+<h1>Derby Logging and Recovery</h1>
+<div class="abstract">This document describes how Derby implements logging and recovery.
+ This is a work-in-progress derived from Javadoc comments and from explanations
+ Mike Matrigali and others posted to the Derby lists. Please post questions,
+ comments, and corrections to derby-dev@db.apache.org. </div>
+<div id="minitoc-area">
+<ul class="minitoc">
+<li>
+<a href="#introduction"> Introduction </a>
+</li>
+<li>
+<a href="#ARIES+-+An+Overview">ARIES - An Overview</a>
+</li>
+<li>
+<a href="#Features+of+ARIES">Features of ARIES</a>
+</li>
+<li>
+<a href="#References">References</a>
+</li>
+<li>
+<a href="#Derby+implementation+of+ARIES">Derby implementation of ARIES</a>
+</li>
+<li>
+<a href="#Derby+recovery+process">Derby recovery process</a>
+</li>
+<li>
+<a href="#Recovery+Redo+pass">Recovery Redo pass</a>
+</li>
+<li>
+<a href="#Recovery+Undo+pass">Recovery Undo pass</a>
+</li>
+<li>
+<a href="#Checkpoints">Checkpoints</a>
+</li>
+</ul>
+</div>
+
+<a name="N1000F"></a><a name="introduction"></a>
+<h2 class="boxed"> Introduction </h2>
+<div class="section">
+<p>Derby transaction logging and recovery is based upon the ARIES algorithm.</p>
+</div>
+
+<a name="N10019"></a><a name="ARIES+-+An+Overview"></a>
+<h2 class="boxed">ARIES - An Overview</h2>
+<div class="section">
+<p>Following is a brief description of the main principles behind ARIES.</p>
+<p>Firstly, in ARIES, changes always take the system forward. That is to
+ say, even transaction rollbacks are treated as if they are updates to
+ the system. For example, if a transaction changes A to B and then rolls
+ back, ARIES treats the rollback as simply an update that changes B to
+ A. The forward change from A to B (redo) and the reversal of B to A (undo)
+ are both recorded as updates to the system.</p>
+<p>One can see that this simple principle ensures that all changes within
+ the system are recorded as updates that forever take the system forward.
+ </p>
+<p>The second basic principle of ARIES is that during recovery, history
+ is repeated. This can be explained as follows.</p>
+<p>When a system crashes, there would be some transactions that have completed
+ (committed or aborted), and others that are still active. The WAL protocol
+ ensures that changes made by completed transactions have been recorded
+ in the Log. Changes made by incomplete transactions may also be present
+ in the Log, because Log Records are created in the same order as the changes
+ are made by the system.</p>
+<p>During recovery, ARIES initially replays the Log to the bring the system
+ back to a state close to that when the crash occurred. This means that
+ ARIES replays the effects of not only those transactions that committed
+ or aborted, but also those that were active at the time of the crash.
+ Having brought the system to this state, ARIES then identifies transactions
+ that were incomplete, and rolls them back. The basic idea is to repeat
+ the entire history upto the point of crash, and then undo failed transactions.</p>
+<p>This approach has the advantage that during the redo phase, changes can
+ be replayed at a fairly low level, for example, the level of a disk page.
+ ARIES calls this page oriented redo. This feature is significant because
+ it means that until the redo phase is over, the system does not need to
+ know about higher level data structures such as Indexes. Only during the
+ undo phase, when incomplete transactions are being rolled back, does the
+ system need to know about high level data structures. </p>
+</div>
+
+<a name="N10035"></a><a name="Features+of+ARIES"></a>
+<h2 class="boxed">Features of ARIES</h2>
+<div class="section">
+<p>ARIES includes a number of optimisations to reduce the amount of work
+ required during normal operations and recovery.</p>
+<p>One optimisation is to avoid application of log records unnecessarily.
+ The LSN of the most recently generated log record is stored in each disk
+ page. This is known as the PageLsn. The PageLsn allows ARIES to determine
+ during the redo phase, whether the changes represented by a log record
+ have been applied to the page or not.</p>
+<p>ARIES chains log records for transactions in such a way that those records
+ that are no longer necessary, are skipped during recovery. For example,
+ if a transaction changed A to B, and then rolled back, generating a log
+ record for changing B to A, then during recovery, ARIES would automatically
+ skip the log record that represents the change from A to B. This is made
+ possible by maintaining a UndoLsn pointer in every Log Record. The UndoLsn
+ normally points to the previous log record generated by the transaction.
+ However, in log records generated during Rollback (known as Compensation
+ Log Records), the UndoLsn is made to point to the Log record preceding
+ the one that is being undone. To take an example, let us assume that a
+ transaction generated log record 1, containing change from A to B, then
+ log record 2 containing change from B to C. At this point the transaction
+ decides to rollback the change from B to C. It therefore generates a new
+ log record 3, containing a change from C to B. The UndoLsn of this log
+ record is made to point at log record 1, instead of log record 2. When
+ following the UndoLsn chain, ARIES would skip log record 2.</p>
+<p>ARIES also supports efficient checkpoints. During a checkpoint, it is
+ not necessary to flush all database pages to disk. Instead ARIES records
+ a list of dirty buffer pages along with their RecoveryLsn(s). The RecoveryLsn
+ of a page is the LSN of the earliest log record that represents a change
+ to the page since it was read from disk. By using this list, ARIES is
+ able to determine during recovery, where to start replaying the Log.</p>
+<p>ARIES supports nested top-level action concept whereby part of a transaction
+ can be commited even if the transaction aborts. This is useful for situations
+ where a structural change should not be undone even if the transaction
+ aborts. Nested top level actions are implemented using Dummy Compensation
+ Log Records - and make use of the ability to skip logs records using the
+ UndoLsn pointer as described previously.</p>
+</div>
+
+<a name="N1004B"></a><a name="References"></a>
+<h2 class="boxed">References</h2>
+<div class="section">
+<p> For a full description of ARIES, please see
+ <em>Mohan, C., Haderle, D., Lindsay, B., Pirahesh, H., Schwarz, P. ARIES:
+ A Transaction Recovery Method Supporting Fine-Granularity Locking and
+ Partial Rollbacks Using Write-Ahead Logging, ACM Transactions on Database
+ Systems, Vol. 17, No. 1, March 1992, pp94-162.</em>
+ A version of this document is freely available as
+ <a class="external" href="http://www.almaden.ibm.com/u/mohan/RJ6649Rev.pdf">IBM Research
+ Report RJ6649</a>
+ .</p>
+</div>
+
+<a name="N1005C"></a><a name="Derby+implementation+of+ARIES"></a>
+<h2 class="boxed">Derby implementation of ARIES</h2>
+<div class="section">
+<p>I shall only describe how Derby differs from standard ARIES implementation.
+ Therefore, for a full understanding of the logging and recovery mechanisms
+ in Derby, it is necessary to consult above mentioned papers on ARIES.</p>
+<p>Derby uses Log Sequence Numbers to identify Log records. In Derby terminology,
+ LSNs are called LogInstants. LogCounter is an implementation of LogInstant.</p>
+<p>Although Derby uses LogInstant, it does not save this with the page data.
+ Instead, a page version number is stored. The page version number is also
+ stored in the log records associated with the page. During recovery (redo),
+ Derby uses the page version to determine whether the page needs redo or
+ not. Here is a comment on the rationale behind this:</p>
+<p class="quote">
+
+<em>Mike Matrigali:</em>
+
+<br>
+ Am going to defer on page version vs. LSN question, but at least mention
+ some guesses, not researched info. You are right bout what exists. I spoke
+ with some colleagues and the best we can come up with is that the implementor
+ wanted to separate the page and the log, in case we ever did a different
+ log format. I will try to do some more research here. I also vaguely remember
+ the implementor mentioning if we ever wanted to implement the LSN on the
+ page, we had space to do so. It may simply have been easier to code the
+ page versions, since in the current system the LSN is the address in the
+ log file (which and it may not be available when the code wants to write
+ it on the page).
+ <br>
+ As you say in derby all the log records are associated with a page, and
+ thus have a page version number. That page version number in the log is
+ compared with the page version number of the page during redo to determine
+ if the log record needs to be applied. This also has helped us in the
+ past to catch some bugs as we can sanity check during redo that the page
+ is progressing along the expected path, ie. it is a bug during redo to
+ be applying a page version 10 log record to page that is at page version
+ 8. I haven't seen this sanity check in many years, but was useful when
+ the product was first coded. </p>
+<p>Derby does not write the dirty pages list within a Checkpoint record.
+ As a result, during checkpoint, Derby must flush all database pages to
+ disk.</p>
+<p>Derby uses 'internal' transactions instead of nested top-level actions
+ to separate structural changes from normal operations. Internal transactions
+ have the property that they are always page-oriented and do not require
+ logical undo. Also, during recovery, incomplete internal transactions
+ are undone before any regular transactions. In ARIES, no special processing
+ is required to handle this, as nested top-level actions are automatically
+ handled as part of normal redo, and are skipped during undo unless they
+ are incomplete, in which case they are undone.</p>
+<p>ARIES uses three passes during recovery. The first pass is the analysis
+ pass when ARIES collects information and determines where redo must start.
+ This is followed by the redo pass, and then by the undo pass. Derby omits
+ the analysis pass as this is not required due to the way checkpoints are
+ done.</p>
+</div>
+
+<a name="N10080"></a><a name="Derby+recovery+process"></a>
+<h2 class="boxed">Derby recovery process</h2>
+<div class="section">
+<p>Implemented in <span class="codefrag">org.apache.derby.impl.store.raw.log.LogToFile.recover()</span>
+</p>
+<p>Following is a high level description of Derby recovery process in Derby.</p>
+<p> In this implementation, the log is a stream of log records stored in
+ one or more flat files. Recovery is done in 2 passes: redo and undo. </p>
+<dl>
+
+<dt>Redo pass </dt>
+
+<dd> In the redo pass, reconstruct the state of the rawstore by repeating
+ exactly what happened before as recorded in the log. </dd>
+
+<dt>Undo pass </dt>
+
+<dd> In the undo pass, all incomplete transactions are rolled back in
+ the order from the most recently started to the oldest.</dd>
+
+</dl>
+</div>
+
+<a name="N100A1"></a><a name="Recovery+Redo+pass"></a>
+<h2 class="boxed">Recovery Redo pass</h2>
+<div class="section">
+<p>Implemented in <span class="codefrag">org.apache.derby.impl.store.raw.log.FileLogger.redo()</span>
+</p>
+<p> The log stream is scanned from the beginning (or
+ from the undo low water mark of a checkpoint) forward until the end.
+ The purpose of the redo pass is to repeat history, i.e, to repeat
+ exactly the same set of changes the rawStore went thru right before it
+ stopped. With each log record that is encountered in the redo pass:</p>
+<ol>
+
+<li>if it isFirst(), then the transaction factory is called upon to
+ create a new transaction object.</li>
+
+<li>if it needsRedo(), its doMe() is called (if it is a compensation
+ operation, then the undoable operation needs to be created first
+ before the doMe is called).</li>
+
+<li>if it isComplete(), then the transaction object is closed.</li>
+
+</ol>
+</div>
+
+<a name="N100BC"></a><a name="Recovery+Undo+pass"></a>
+<h2 class="boxed">Recovery Undo pass</h2>
+<div class="section">
+<p>Implemented in <span class="codefrag">org.apache.derby.impl.store.raw.xact.XactFactory.rollbackAllTransactions()</span>
+</p>
+<p> Rollback all active transactions that has updated the raw store.
+ Transactions are rolled back in the following order:</p>
+<ol>
+
+<li>Internal transactions in reversed beginXact chronological order</li>
+
+<li>all other transactions in reversed beginXact chronological order</li>
+
+</ol>
+</div>
+
+<a name="N100D4"></a><a name="Checkpoints"></a>
+<h2 class="boxed">Checkpoints</h2>
+<div class="section">
+<p>Implemented in <span class="codefrag">org.apache.derby.impl.store.raw.log.LogToFile.checkpoint()</span>
+</p>
+<p>Only one checkpoint is to be taking place at any given time.</p>
+<p>The steps of a checkpoint are:</p>
+<ol>
+
+<li>
+<p>Switch to a new log file if possible.</p>
+
+<ol>
+
+<li>Freeze the log (for the transition to a new log file)</li>
+
+<li>Flush current log file</li>
+
+<li>Create and flush the new log file (with file number 1 higher
+ than the previous log file). The new log file becomes the
+ current log file.</li>
+
+<li>Unfreeze the log</li>
+
+</ol>
+
+</li>
+
+<li>Start checkpoint transaction</li>
+
+<li>
+<p>Gather interesting information about the rawStore: </p>
+
+<ol>
+
+<li>The current log instant (redoLWM)</li>
+
+<li>The earliest active transaction begin tran log record instant (undoLWM)
+ , all the truncation LWM set by clients of raw store
+ (replication)</li>
+
+</ol>
+
+</li>
+
+<li>Clean the buffer cache</li>
+
+<li>Log the next checkpoint log record, which contains (repPoint,
+ undoLWM, redoLWM) and commit checkpoint transaction.</li>
+
+<li>Synchronously write the control file containing the next checkpoint
+ log record log instant</li>
+
+<li>The new checkpoint becomes the current checkpoint. Somewhere near
+ the beginning of each log file should be a checkpoint log record (not
+ guarenteed to be there)</li>
+
+<li>See if the log can be truncated</li>
+
+</ol>
+<p>The earliest useful log record is determined by the repPoint and the
+ undoLWM, whichever is earlier.</p>
+<p>Every log file whose log file number is smaller than the earliest useful
+ log record's log file number can be deleted.</p>
+<p>Transactions can be at the following states w/r to a checkpoint -
+ consider the log as a continous stream and not as series of log files for
+ the sake of clarity:<br>
+ <!-- <img src="checkpoint.png" alt=""/> -->
+
+</p>
+<pre class="code">
+|(BT)-------(ET)| marks the begin and end of a transaction.
+. checkpoint started
+. |__undoLWM |
+. V |___redoLWM
+. |___TruncationLWM
+. |
+. V
+1 |-----------------|
+2 |--------------------------------|
+3 |-------|
+4 |--------------------------------------(end of log)
+5 |-^-|
+. Checkpoint Log Record
+---A--->|<-------B--------->|<-------------C-----------
+</pre>
+<p>
+ There are only 3 periods of interest :<br>
+ A) before undoLWM, B) between undo and redo LWM, C) after redoLWM.
+ </p>
+<p>
+ Transaction 1 started in A and terminates in B.<br>
+ During redo, we should only see log records and endXact from this
+ transaction in the first phase (between undoLWM and redoLWM). No
+ beginXact log record for this transaction will be seen.
+ </p>
+<p>
+ Transaction 2 started in B (right on the undoLWM) and terminated in C.
+ <br>
+ Any transaction that terminates in C must have a beginXact at or after
+ undoLWM. In other words, no transaction can span A, B and C. During redo,
+ we will see beginXact, other log records and endXact for this
+ transaction.
+ </p>
+<p>
+ Transaction 3 started in B and ended in B.<br>
+ During redo, we will see beginXact, other log records and endXact for
+ this transaction.
+ </p>
+<p>
+ Transaction 4 begins in B and never ends. <br>
+ During redo, we will see beginXact, other log records. In undo, this
+ loser transaction will be rolled back.
+ </p>
+<p>
+ Transaction 5 is the transaction taking the checkpoint. <br>
+ The checkpoint action started way back in time but the checkpoint log
+ record is only written after the buffer cache has been flushed.
+ </p>
+<p>
+ Note that if any time elapse between taking the undoLWM and the redoLWM,
+ then it will create a 4th period of interest.
+ </p>
+</div>
+
+</div>
+<!--+
+ |end content
+ +-->
+<div class="clearboth"> </div>
+</div>
+<div id="footer">
+<!--+
+ |start bottomstrip
+ +-->
+<div class="lastmodified">
+<script type="text/javascript"><!--
+document.write("Last Published: " + document.lastModified);
+// --></script>
+</div>
+<div class="copyright">
+ Copyright © 2004-2005 Apache Software Foundation</div>
+<div id="feedback">
+ Send feedback about the website to:
+ <a id="feedbackto" href="mailto:derby-dev@db.apache.org?subject=Feedback%C2%A0papers/recovery.html">derby-dev@db.apache.org</a>
+</div>
+<!--+
+ |end bottomstrip
+ +-->
+</div>
+</body>
+</html>
Modified: incubator/derby/site/trunk/src/documentation/content/xdocs/papers/index.xml
URL: http://svn.apache.org/viewcvs/incubator/derby/site/trunk/src/documentation/content/xdocs/papers/index.xml?view=diff&r1=151285&r2=151286
==============================================================================
--- incubator/derby/site/trunk/src/documentation/content/xdocs/papers/index.xml (original)
+++ incubator/derby/site/trunk/src/documentation/content/xdocs/papers/index.xml Thu Feb 3 17:50:21 2005
@@ -23,6 +23,7 @@
<li>JDBC: <a href="JDBCImplementation.html">Derby JDBC Implementation
Notes</a></li>
<li>Log Format: <a href="logformats.html">Derby Write Ahead Log Format</a></li>
+ <li>Logging & Recovery: <a href="recovery.html">Derby Logging and Recovery</a></li>
</ul>
</section>
@@ -175,6 +176,6 @@
</section>
-<p><em>Last Updated: January 31, 2005</em></p>
+<p><em>Last Updated: February 3, 2005</em></p>
</body>
</document>
Added: incubator/derby/site/trunk/src/documentation/content/xdocs/papers/recovery.xml
URL: http://svn.apache.org/viewcvs/incubator/derby/site/trunk/src/documentation/content/xdocs/papers/recovery.xml?view=auto&rev=151286
==============================================================================
--- incubator/derby/site/trunk/src/documentation/content/xdocs/papers/recovery.xml (added)
+++ incubator/derby/site/trunk/src/documentation/content/xdocs/papers/recovery.xml Thu Feb 3 17:50:21 2005
@@ -0,0 +1,297 @@
+<?xml version="1.0"?>
+ <!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V2.0//EN" "http://forrest.apache.org/dtd/document-v20.dtd">
+ <document>
+ <header>
+ <title>Derby Logging and Recovery</title>
+ <abstract>This document describes how Derby implements logging and recovery.
+ This is a work-in-progress derived from Javadoc comments and from explanations
+ Mike Matrigali and others posted to the Derby lists. Please post questions,
+ comments, and corrections to derby-dev@db.apache.org. </abstract>
+ </header>
+ <body>
+ <section id="introduction">
+ <title> Introduction </title>
+ <p>Derby transaction logging and recovery is based upon the ARIES algorithm.</p>
+ </section>
+ <section>
+ <title>ARIES - An Overview</title>
+ <p>Following is a brief description of the main principles behind ARIES.</p>
+ <p>Firstly, in ARIES, changes always take the system forward. That is to
+ say, even transaction rollbacks are treated as if they are updates to
+ the system. For example, if a transaction changes A to B and then rolls
+ back, ARIES treats the rollback as simply an update that changes B to
+ A. The forward change from A to B (redo) and the reversal of B to A (undo)
+ are both recorded as updates to the system.</p>
+ <p>One can see that this simple principle ensures that all changes within
+ the system are recorded as updates that forever take the system forward.
+ </p>
+ <p>The second basic principle of ARIES is that during recovery, history
+ is repeated. This can be explained as follows.</p>
+ <p>When a system crashes, there would be some transactions that have completed
+ (committed or aborted), and others that are still active. The WAL protocol
+ ensures that changes made by completed transactions have been recorded
+ in the Log. Changes made by incomplete transactions may also be present
+ in the Log, because Log Records are created in the same order as the changes
+ are made by the system.</p>
+ <p>During recovery, ARIES initially replays the Log to the bring the system
+ back to a state close to that when the crash occurred. This means that
+ ARIES replays the effects of not only those transactions that committed
+ or aborted, but also those that were active at the time of the crash.
+ Having brought the system to this state, ARIES then identifies transactions
+ that were incomplete, and rolls them back. The basic idea is to repeat
+ the entire history upto the point of crash, and then undo failed transactions.</p>
+ <p>This approach has the advantage that during the redo phase, changes can
+ be replayed at a fairly low level, for example, the level of a disk page.
+ ARIES calls this page oriented redo. This feature is significant because
+ it means that until the redo phase is over, the system does not need to
+ know about higher level data structures such as Indexes. Only during the
+ undo phase, when incomplete transactions are being rolled back, does the
+ system need to know about high level data structures. </p>
+ </section>
+ <section>
+ <title>Features of ARIES</title>
+ <p>ARIES includes a number of optimisations to reduce the amount of work
+ required during normal operations and recovery.</p>
+ <p>One optimisation is to avoid application of log records unnecessarily.
+ The LSN of the most recently generated log record is stored in each disk
+ page. This is known as the PageLsn. The PageLsn allows ARIES to determine
+ during the redo phase, whether the changes represented by a log record
+ have been applied to the page or not.</p>
+ <p>ARIES chains log records for transactions in such a way that those records
+ that are no longer necessary, are skipped during recovery. For example,
+ if a transaction changed A to B, and then rolled back, generating a log
+ record for changing B to A, then during recovery, ARIES would automatically
+ skip the log record that represents the change from A to B. This is made
+ possible by maintaining a UndoLsn pointer in every Log Record. The UndoLsn
+ normally points to the previous log record generated by the transaction.
+ However, in log records generated during Rollback (known as Compensation
+ Log Records), the UndoLsn is made to point to the Log record preceding
+ the one that is being undone. To take an example, let us assume that a
+ transaction generated log record 1, containing change from A to B, then
+ log record 2 containing change from B to C. At this point the transaction
+ decides to rollback the change from B to C. It therefore generates a new
+ log record 3, containing a change from C to B. The UndoLsn of this log
+ record is made to point at log record 1, instead of log record 2. When
+ following the UndoLsn chain, ARIES would skip log record 2.</p>
+ <p>ARIES also supports efficient checkpoints. During a checkpoint, it is
+ not necessary to flush all database pages to disk. Instead ARIES records
+ a list of dirty buffer pages along with their RecoveryLsn(s). The RecoveryLsn
+ of a page is the LSN of the earliest log record that represents a change
+ to the page since it was read from disk. By using this list, ARIES is
+ able to determine during recovery, where to start replaying the Log.</p>
+ <p>ARIES supports nested top-level action concept whereby part of a transaction
+ can be commited even if the transaction aborts. This is useful for situations
+ where a structural change should not be undone even if the transaction
+ aborts. Nested top level actions are implemented using Dummy Compensation
+ Log Records - and make use of the ability to skip logs records using the
+ UndoLsn pointer as described previously.</p>
+ </section>
+ <section>
+ <title>References</title>
+ <p> For a full description of ARIES, please see
+ <em>Mohan, C., Haderle, D., Lindsay, B., Pirahesh, H., Schwarz, P. ARIES:
+ A Transaction Recovery Method Supporting Fine-Granularity Locking and
+ Partial Rollbacks Using Write-Ahead Logging, ACM Transactions on Database
+ Systems, Vol. 17, No. 1, March 1992, pp94-162.</em>
+ A version of this document is freely available as
+ <a href="http://www.almaden.ibm.com/u/mohan/RJ6649Rev.pdf">IBM Research
+ Report RJ6649</a>
+ .</p>
+ </section>
+ <section>
+ <title>Derby implementation of ARIES</title>
+ <p>I shall only describe how Derby differs from standard ARIES implementation.
+ Therefore, for a full understanding of the logging and recovery mechanisms
+ in Derby, it is necessary to consult above mentioned papers on ARIES.</p>
+ <p>Derby uses Log Sequence Numbers to identify Log records. In Derby terminology,
+ LSNs are called LogInstants. LogCounter is an implementation of LogInstant.</p>
+ <p>Although Derby uses LogInstant, it does not save this with the page data.
+ Instead, a page version number is stored. The page version number is also
+ stored in the log records associated with the page. During recovery (redo),
+ Derby uses the page version to determine whether the page needs redo or
+ not. Here is a comment on the rationale behind this:</p>
+ <p class="quote">
+ <em>Mike Matrigali:</em>
+ <br/>
+ Am going to defer on page version vs. LSN question, but at least mention
+ some guesses, not researched info. You are right bout what exists. I spoke
+ with some colleagues and the best we can come up with is that the implementor
+ wanted to separate the page and the log, in case we ever did a different
+ log format. I will try to do some more research here. I also vaguely remember
+ the implementor mentioning if we ever wanted to implement the LSN on the
+ page, we had space to do so. It may simply have been easier to code the
+ page versions, since in the current system the LSN is the address in the
+ log file (which and it may not be available when the code wants to write
+ it on the page).
+ <br/>
+ As you say in derby all the log records are associated with a page, and
+ thus have a page version number. That page version number in the log is
+ compared with the page version number of the page during redo to determine
+ if the log record needs to be applied. This also has helped us in the
+ past to catch some bugs as we can sanity check during redo that the page
+ is progressing along the expected path, ie. it is a bug during redo to
+ be applying a page version 10 log record to page that is at page version
+ 8. I haven't seen this sanity check in many years, but was useful when
+ the product was first coded. </p>
+ <p>Derby does not write the dirty pages list within a Checkpoint record.
+ As a result, during checkpoint, Derby must flush all database pages to
+ disk.</p>
+ <p>Derby uses 'internal' transactions instead of nested top-level actions
+ to separate structural changes from normal operations. Internal transactions
+ have the property that they are always page-oriented and do not require
+ logical undo. Also, during recovery, incomplete internal transactions
+ are undone before any regular transactions. In ARIES, no special processing
+ is required to handle this, as nested top-level actions are automatically
+ handled as part of normal redo, and are skipped during undo unless they
+ are incomplete, in which case they are undone.</p>
+ <p>ARIES uses three passes during recovery. The first pass is the analysis
+ pass when ARIES collects information and determines where redo must start.
+ This is followed by the redo pass, and then by the undo pass. Derby omits
+ the analysis pass as this is not required due to the way checkpoints are
+ done.</p>
+ </section>
+ <section>
+ <title>Derby recovery process</title>
+ <p>Implemented in <code>org.apache.derby.impl.store.raw.log.LogToFile.recover()</code></p>
+ <p>Following is a high level description of Derby recovery process in Derby.</p>
+ <p> In this implementation, the log is a stream of log records stored in
+ one or more flat files. Recovery is done in 2 passes: redo and undo. </p>
+ <dl>
+ <dt>Redo pass </dt>
+ <dd> In the redo pass, reconstruct the state of the rawstore by repeating
+ exactly what happened before as recorded in the log. </dd>
+ <dt>Undo pass </dt>
+ <dd> In the undo pass, all incomplete transactions are rolled back in
+ the order from the most recently started to the oldest.</dd>
+ </dl>
+ </section>
+ <section>
+ <title>Recovery Redo pass</title>
+ <p>Implemented in <code>org.apache.derby.impl.store.raw.log.FileLogger.redo()</code></p>
+ <p> The log stream is scanned from the beginning (or
+ from the undo low water mark of a checkpoint) forward until the end.
+ The purpose of the redo pass is to repeat history, i.e, to repeat
+ exactly the same set of changes the rawStore went thru right before it
+ stopped. With each log record that is encountered in the redo pass:</p>
+ <ol>
+ <li>if it isFirst(), then the transaction factory is called upon to
+ create a new transaction object.</li>
+ <li>if it needsRedo(), its doMe() is called (if it is a compensation
+ operation, then the undoable operation needs to be created first
+ before the doMe is called).</li>
+ <li>if it isComplete(), then the transaction object is closed.</li>
+ </ol>
+ </section>
+ <section>
+ <title>Recovery Undo pass</title>
+ <p>Implemented in <code>org.apache.derby.impl.store.raw.xact.XactFactory.rollbackAllTransactions()</code></p>
+ <p> Rollback all active transactions that has updated the raw store.
+ Transactions are rolled back in the following order:</p>
+ <ol>
+ <li>Internal transactions in reversed beginXact chronological order</li>
+ <li>all other transactions in reversed beginXact chronological order</li>
+ </ol>
+ </section>
+ <section>
+ <title>Checkpoints</title>
+ <p>Implemented in <code>org.apache.derby.impl.store.raw.log.LogToFile.checkpoint()</code></p>
+ <p>Only one checkpoint is to be taking place at any given time.</p>
+ <p>The steps of a checkpoint are:</p>
+ <ol>
+ <li><p>Switch to a new log file if possible.</p>
+ <ol>
+ <li>Freeze the log (for the transition to a new log file)</li>
+ <li>Flush current log file</li>
+ <li>Create and flush the new log file (with file number 1 higher
+ than the previous log file). The new log file becomes the
+ current log file.</li>
+ <li>Unfreeze the log</li>
+ </ol>
+ </li>
+ <li>Start checkpoint transaction</li>
+ <li><p>Gather interesting information about the rawStore: </p>
+ <ol>
+ <li>The current log instant (redoLWM)</li>
+ <li>The earliest active transaction begin tran log record instant (undoLWM)
+ , all the truncation LWM set by clients of raw store
+ (replication)</li>
+ </ol>
+ </li>
+ <li>Clean the buffer cache</li>
+ <li>Log the next checkpoint log record, which contains (repPoint,
+ undoLWM, redoLWM) and commit checkpoint transaction.</li>
+ <li>Synchronously write the control file containing the next checkpoint
+ log record log instant</li>
+ <li>The new checkpoint becomes the current checkpoint. Somewhere near
+ the beginning of each log file should be a checkpoint log record (not
+ guarenteed to be there)</li>
+ <li>See if the log can be truncated</li>
+ </ol>
+ <p>The earliest useful log record is determined by the repPoint and the
+ undoLWM, whichever is earlier.</p>
+ <p>Every log file whose log file number is smaller than the earliest useful
+ log record's log file number can be deleted.</p>
+ <p>Transactions can be at the following states w/r to a checkpoint -
+ consider the log as a continous stream and not as series of log files for
+ the sake of clarity:<br/>
+ <!-- <img src="checkpoint.png" alt=""/> -->
+ </p>
+<source>
+|(BT)-------(ET)| marks the begin and end of a transaction.
+. checkpoint started
+. |__undoLWM |
+. V |___redoLWM
+. |___TruncationLWM
+. |
+. V
+1 |-----------------|
+2 |--------------------------------|
+3 |-------|
+4 |--------------------------------------(end of log)
+5 |-^-|
+. Checkpoint Log Record
+---A--->|<-------B--------->|<-------------C-----------
+</source>
+ <p>
+ There are only 3 periods of interest :<br/>
+ A) before undoLWM, B) between undo and redo LWM, C) after redoLWM.
+ </p>
+ <p>
+ Transaction 1 started in A and terminates in B.<br/>
+ During redo, we should only see log records and endXact from this
+ transaction in the first phase (between undoLWM and redoLWM). No
+ beginXact log record for this transaction will be seen.
+ </p>
+ <p>
+ Transaction 2 started in B (right on the undoLWM) and terminated in C.
+ <br/>
+ Any transaction that terminates in C must have a beginXact at or after
+ undoLWM. In other words, no transaction can span A, B and C. During redo,
+ we will see beginXact, other log records and endXact for this
+ transaction.
+ </p>
+ <p>
+ Transaction 3 started in B and ended in B.<br/>
+ During redo, we will see beginXact, other log records and endXact for
+ this transaction.
+ </p>
+ <p>
+ Transaction 4 begins in B and never ends. <br/>
+ During redo, we will see beginXact, other log records. In undo, this
+ loser transaction will be rolled back.
+ </p>
+ <p>
+ Transaction 5 is the transaction taking the checkpoint. <br/>
+ The checkpoint action started way back in time but the checkpoint log
+ record is only written after the buffer cache has been flushed.
+ </p>
+ <p>
+ Note that if any time elapse between taking the undoLWM and the redoLWM,
+ then it will create a 4th period of interest.
+ </p>
+ </section>
+ </body>
+ <footer>
+ <legal></legal>
+ </footer>
+ </document>
Modified: incubator/derby/site/trunk/src/documentation/content/xdocs/site.xml
URL: http://svn.apache.org/viewcvs/incubator/derby/site/trunk/src/documentation/content/xdocs/site.xml?view=diff&r1=151285&r2=151286
==============================================================================
--- incubator/derby/site/trunk/src/documentation/content/xdocs/site.xml (original)
+++ incubator/derby/site/trunk/src/documentation/content/xdocs/site.xml Thu Feb 3 17:50:21 2005
@@ -30,6 +30,7 @@
<misc label="How Things Work" href="derby_htw.html"/>
<jdbc label="JDBC" href="JDBCImplementation.html"/>
<log label="Log Format" href="logformats.html"/>
+ <recover label="Logging & Recovery" href="recovery.html"/>
</engine>
<how_to label="Integration" href="papers/" tab="papers">