Allow WAL information to recover corrupted pg_controldata - Mailing list pgsql-hackers
From | Amit Kapila |
---|---|
Subject | Allow WAL information to recover corrupted pg_controldata |
Date | |
Msg-id | 001601cd4a43$d65373b0$82fa5b10$@kapila@huawei.com Whole thread Raw |
List | pgsql-hackers |
<div class="WordSection1"><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">I am planningto work on the below Todo list item for this CommitFest</span><br /><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">AllowWAL information to recover corrupted pg_controldata </span><br/><span style="font-size:10.0pt;font-family:"Arial","sans-serif""><a href="http://archives.postgresql.org/pgsql-patches/2006-06/msg00025.php">http://archives.postgresql.org/pgsql-patches/2006-06/msg00025.php</a></span><br /><spanstyle="font-size:10.0pt;font-family:"Arial","sans-serif""> </span><br /><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">Iwanted to confirm my understanding about the work involved forthis patch:</span><br /><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">The existing patch has followingset of problems:</span><br /><span style="font-size:10.0pt;font-family:"Arial","sans-serif""> 1. Memory leak andlinked list code path is not proper</span><br /><span style="font-size:10.0pt;font-family:"Arial","sans-serif""> 2.lock check for if the server is already running, is removed in patch which needs to be reverted</span><br /><span style="font-size:10.0pt;font-family:"Arial","sans-serif""> 3. Refactoring of the code.</span><br /><span style="font-size:10.0pt;font-family:"Arial","sans-serif""> </span><br /><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">Apartfrom above what I understood from the patch is that its intentionis to generate values for ControlFile using WAL logs when -r option is used.</span><br /><span style="font-size:10.0pt;font-family:"Arial","sans-serif""> </span><br /><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">Thechange in algorithm from current will be if control file iscorrupt which</span> <span style="font-size:10.0pt;font-family:"Arial","sans-serif"">essentialy means ReadControlFile()will return False, then it should</span><br /><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">generatevalues (checkPointCopy, checkPoint, prevCheckPoint, state)using WAL if -r option is enabled.</span><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">Alsofor -r option, it doesn't need to call function FindEndOfXLOG()as the that work will be achieved</span> <span style="font-size:10.0pt;font-family:"Arial","sans-serif"">byabove point. </span><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">Itwill just rewrite the control file and don’t do other resets.</span><br/><span style="font-size:10.0pt;font-family:"Arial","sans-serif""> </span><br /><span style="font-size:10.0pt;font-family:"Arial","sans-serif""> </span><br/><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">Thealgorithm of restoring the pg_control value from old xlog file:</span><br/><span style="font-size:10.0pt;font-family:"Arial","sans-serif""> 1. Retrieve all of the active xlog filesfrom xlog direcotry into a list by increasing order, according their timeline, log id, segment id.</span><br /><spanstyle="font-size:10.0pt;font-family:"Arial","sans-serif""> 2. Search the list to find the oldest xlog file of thelastest time line.</span><br /><span style="font-size:10.0pt;font-family:"Arial","sans-serif""> 3. Search the recordsfrom the oldest xlog file of latest time line</span> <span style="font-size:10.0pt;font-family:"Arial","sans-serif"">tothe latest xlog file of latest time line, if the checkpoint record</span><br/><span style="font-size:10.0pt;font-family:"Arial","sans-serif""> has been found, update the latestcheckpoint and previous checkpoint.</span><p class="MsoNormal"> <p class="MsoNormal">Apart from above some changesin code will be required after the Xlog patch by Heikki.<br /><span style="font-size:10.0pt;font-family:"Arial","sans-serif""> </span><br /><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">Suggestme if my understanding is correct?</span><p class="MsoNormal"> <pclass="MsoNormal"> <p class="MsoNormal"> </div>
pgsql-hackers by date: