forked from docs/doc-exports
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com> Co-authored-by: Lu, Huayi <luhuayi@huawei.com> Co-committed-by: Lu, Huayi <luhuayi@huawei.com>
56 lines
13 KiB
HTML
56 lines
13 KiB
HTML
<a name="EN-US_TOPIC_0000001494853537"></a><a name="EN-US_TOPIC_0000001494853537"></a>
|
|
|
|
<h1 class="topictitle1">Residual File Management Functions</h1>
|
|
<div id="body0000001494853537"><div class="section" id="EN-US_TOPIC_0000001494853537__section9477262510"><h4 class="sectiontitle">Procedure</h4><ol id="EN-US_TOPIC_0000001494853537__ol12611223115118"><li id="EN-US_TOPIC_0000001494853537__li3611023105117"><span>Call the <strong id="EN-US_TOPIC_0000001494853537__b99916941921746">pgxc_get_residualfiles()</strong> function to obtain the name of the database that has residual files.</span></li><li id="EN-US_TOPIC_0000001494853537__li461223105116"><span>Go to the databases where residual files exist and call the <strong id="EN-US_TOPIC_0000001494853537__b4084407019370">pgxc_verify_residualfiles()</strong> function to verify the residual files recorded in the current database.</span></li><li id="EN-US_TOPIC_0000001494853537__li116114234519"><span>Call the pgxc_rm_residualfiles() function to delete all the verified residual files.</span></li></ol>
|
|
<div class="note" id="EN-US_TOPIC_0000001494853537__note13746144255117"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001494853537__p11746104245120">The pgxc residual file management function only operates on the CN and the current primary DN, and does not verify or clear residual files on the standby DN. Therefore, after the primary DN is cleared, you need to clear residual files on the standby DN or build the standby DN in a timely manner. This prevents residual files on the standby DN from being copied back to the primary DN due to incremental build after a primary/standby switchover.</p>
|
|
</div></div>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001494853537__section4903435135119"><h4 class="sectiontitle">Examples</h4><p id="EN-US_TOPIC_0000001494853537__p125205123524">The following example uses two user-created databases, <strong id="EN-US_TOPIC_0000001494853537__b133893866721746">db1</strong> and <strong id="EN-US_TOPIC_0000001494853537__b134900629121746">db2</strong>.</p>
|
|
<p id="EN-US_TOPIC_0000001494853537__p1452081214528"><span><img id="EN-US_TOPIC_0000001494853537__image15520912125214" src="figure/en-us_image_0000001701787069.png"></span></p>
|
|
<ol id="EN-US_TOPIC_0000001494853537__ol1352012120521"><li id="EN-US_TOPIC_0000001494853537__li852121220524">Run the following command to obtain all residual file records of the cluster on the CNs:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001494853537__screen95215127523"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="n">db1</span><span class="o">=#</span><span class="w"> </span><span class="k">select</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="k">from</span><span class="w"> </span><span class="n">pgxc_get_residualfiles</span><span class="p">()</span><span class="w"> </span><span class="k">order</span><span class="w"> </span><span class="k">by</span><span class="w"> </span><span class="mi">4</span><span class="p">,</span><span class="w"> </span><span class="mi">6</span><span class="p">;</span><span class="w"> </span><span class="c1">-- order by is optional.</span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
<p id="EN-US_TOPIC_0000001494853537__p75211112135215"><span><img id="EN-US_TOPIC_0000001494853537__image35211412115216" src="figure/en-us_image_0000001701706305.png"></span></p>
|
|
<p id="EN-US_TOPIC_0000001494853537__p5521131219526">In the current cluster:</p>
|
|
<ul id="EN-US_TOPIC_0000001494853537__ul14521111245210"><li id="EN-US_TOPIC_0000001494853537__li1521912155213">Residual file records exist in the <strong id="EN-US_TOPIC_0000001494853537__b3528155689370">db1</strong> and <strong id="EN-US_TOPIC_0000001494853537__b14840360159370">db2</strong> databases on the <strong id="EN-US_TOPIC_0000001494853537__b4425170829370">dn_6001_6002</strong> node (active node instance).</li><li id="EN-US_TOPIC_0000001494853537__li20521151219522">Residual files are displayed in the <strong id="EN-US_TOPIC_0000001494853537__b19413390629370">residualfile</strong> column.</li><li id="EN-US_TOPIC_0000001494853537__li15211312105218">The <strong id="EN-US_TOPIC_0000001494853537__b7797132729370">filepath</strong> column lists the files that record residual files. These files are stored in the <strong id="EN-US_TOPIC_0000001494853537__b3403068719370">pg_residualfiles</strong> directory under the instance data directory.</li></ul>
|
|
</li><li id="EN-US_TOPIC_0000001494853537__li752171225219">Call the <strong id="EN-US_TOPIC_0000001494853537__b16171339569370">pgxc_verify_residualfiles()</strong> function to verify the db1 database.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001494853537__screen1952116123522"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="n">db1</span><span class="o">=#</span><span class="w"> </span><span class="k">SELECT</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">pgxc_verify_residualfiles</span><span class="p">();</span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
<p id="EN-US_TOPIC_0000001494853537__p115211112175215"><span><img id="EN-US_TOPIC_0000001494853537__image1521201235219" src="figure/en-us_image_0000001653427544.png"></span></p>
|
|
<p id="EN-US_TOPIC_0000001494853537__p152118126525">Verification functions are at the database level. Therefore, when a verification function is called in the <strong id="EN-US_TOPIC_0000001494853537__b115384717221746">db1</strong> database, it only verifies residual files in <strong id="EN-US_TOPIC_0000001494853537__b81510741421746">db1</strong>.</p>
|
|
<p id="EN-US_TOPIC_0000001494853537__p052161295215">You can call the <strong id="EN-US_TOPIC_0000001494853537__b19792297709370">get</strong> function again to check whether the verification is complete.</p>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001494853537__screen12522111218525"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="n">db1</span><span class="o">=#</span><span class="w"> </span><span class="k">SELECT</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">pgxc_get_residualfiles</span><span class="p">()</span><span class="w"> </span><span class="k">order</span><span class="w"> </span><span class="k">by</span><span class="w"> </span><span class="mi">4</span><span class="p">,</span><span class="w"> </span><span class="mi">6</span><span class="p">;</span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
<p id="EN-US_TOPIC_0000001494853537__p1052211225211"><span><img id="EN-US_TOPIC_0000001494853537__image155221612115213" src="figure/en-us_image_0000001653586852.png"></span></p>
|
|
<p id="EN-US_TOPIC_0000001494853537__p15228123529">As shown in the preceding figure, the residual files in the <strong id="EN-US_TOPIC_0000001494853537__b94572061321746">db1</strong> database have been verified, and the residual files in the db2 database are not verified.</p>
|
|
</li><li id="EN-US_TOPIC_0000001494853537__li4522312125215">Call the <strong id="EN-US_TOPIC_0000001494853537__b7952491929370">pgxc_rm_residualfiles()</strong> function to delete residual files.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001494853537__screen20522111275210"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="n">db1</span><span class="o">=#</span><span class="w"> </span><span class="k">SELECT</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">pgxc_rm_residualfiles</span><span class="p">();</span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
<p id="EN-US_TOPIC_0000001494853537__p11522131219526"><span><img id="EN-US_TOPIC_0000001494853537__image10522612125214" src="figure/en-us_image_0000001701787073.png"></span></p>
|
|
</li><li id="EN-US_TOPIC_0000001494853537__li952213122529">Call the <strong id="EN-US_TOPIC_0000001494853537__b96622920021746">pgxc_get_residualfiles()</strong> function again to check the deletion result.<p id="EN-US_TOPIC_0000001494853537__p85229122527"><span><img id="EN-US_TOPIC_0000001494853537__image16522101220522" src="figure/en-us_image_0000001701706309.png"></span></p>
|
|
<p id="EN-US_TOPIC_0000001494853537__p9522161235216">The result shows that the residual files in the <strong id="EN-US_TOPIC_0000001494853537__b5451281521746">db1</strong> database are deleted (<strong id="EN-US_TOPIC_0000001494853537__b193277410721746">isdeleted</strong> is marked as <strong id="EN-US_TOPIC_0000001494853537__b100117017221746">t</strong>) and the residual files in the <strong id="EN-US_TOPIC_0000001494853537__b99388045921746">db2</strong> database are not deleted.</p>
|
|
<p id="EN-US_TOPIC_0000001494853537__p16522612155217">In addition, nine query results are displayed. Compared with the previous query results, a record for the residual file ending with <strong id="EN-US_TOPIC_0000001494853537__b4995932269370">9438</strong> is missing. This is because the record file that records the residual file ending with <strong id="EN-US_TOPIC_0000001494853537__b139685853421746">9438</strong> contains only one record, which is deleted in step 3. If all residual files in a record file are deleted, the record file is also deleted. Deleted files are backed up in the <strong id="EN-US_TOPIC_0000001494853537__b11311409121746">pg_residualfiles/backup</strong> directory.</p>
|
|
<p id="EN-US_TOPIC_0000001494853537__p125221412145219"><span><img id="EN-US_TOPIC_0000001494853537__image135222125524" src="figure/en-us_image_0000001653427548.png"></span></p>
|
|
</li><li id="EN-US_TOPIC_0000001494853537__li12522121220522">To delete files from the <strong id="EN-US_TOPIC_0000001494853537__b167010247521746">db2</strong> database, you need to call the <strong id="EN-US_TOPIC_0000001494853537__b97443958221746">verify</strong> function in the <strong id="EN-US_TOPIC_0000001494853537__b87796057421746">db2</strong> database and then call the <strong id="EN-US_TOPIC_0000001494853537__b86760522021746">rm</strong> function.<ol type="a" id="EN-US_TOPIC_0000001494853537__ol14522191255211"><li id="EN-US_TOPIC_0000001494853537__li75225121523">Go to the <strong id="EN-US_TOPIC_0000001494853537__b192356084021746">db2</strong> database and call the verification function.<p id="EN-US_TOPIC_0000001494853537__p65221112125213"><span><img id="EN-US_TOPIC_0000001494853537__image1522151255211" src="figure/en-us_image_0000001653586856.png"></span></p>
|
|
<p id="EN-US_TOPIC_0000001494853537__p1523161218523">Query the verification result:</p>
|
|
<p id="EN-US_TOPIC_0000001494853537__p1052314124522"><span><img id="EN-US_TOPIC_0000001494853537__image1052315128523" src="figure/en-us_image_0000001701787077.png"></span></p>
|
|
</li><li id="EN-US_TOPIC_0000001494853537__li4523121205216">Call the deletion function:<p id="EN-US_TOPIC_0000001494853537__p20523101265217"><a name="EN-US_TOPIC_0000001494853537__li4523121205216"></a><a name="li4523121205216"></a><span><img id="EN-US_TOPIC_0000001494853537__image1152317129524" src="figure/en-us_image_0000001701706313.png"></span></p>
|
|
</li><li id="EN-US_TOPIC_0000001494853537__li16523712125218">Query the deletion result:<p id="EN-US_TOPIC_0000001494853537__p1652311219529"><a name="EN-US_TOPIC_0000001494853537__li16523712125218"></a><a name="li16523712125218"></a><span><img id="EN-US_TOPIC_0000001494853537__image9523161219528" src="figure/en-us_image_0000001653427552.png"></span></p>
|
|
<p id="EN-US_TOPIC_0000001494853537__p8523712155214">All residual files recorded in the record file whose name ends with <strong id="EN-US_TOPIC_0000001494853537__b73284456121746">8342</strong> have been deleted, so the record file is deleted and backed up in the <strong id="EN-US_TOPIC_0000001494853537__b95104314821746">backup</strong> directory. As a result, no records are found.</p>
|
|
<p id="EN-US_TOPIC_0000001494853537__p195237121521"><span><img id="EN-US_TOPIC_0000001494853537__image24901822104619" src="figure/en-us_image_0000001653586860.png"></span></p>
|
|
</li></ol>
|
|
</li></ol>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_06_0060.html">Residual File Management Functions</a></div>
|
|
</div>
|
|
</div>
|
|
|