Regarding WAL Format Changes - Mailing list pgsql-hackers

From Amit Kapila
Subject Regarding WAL Format Changes
Date
Msg-id 008701cd546f$2af3b490$80db1db0$@kapila@huawei.com
Whole thread Raw
List pgsql-hackers
<div class="WordSection1"><p class="MsoNormal">While reading patch-1 (<b><a
href="http://archives.postgresql.org/pgsql-hackers/2012-06/txtFskHiYakjO.txt"><span
style="color:windowtext;font-weight:normal;text-decoration:none">1-use-uint64-got-segno.patch</span></a></b>)of WAL
FormatChanges(http://archives.postgresql.org/message-id/4FDA5136.6080206@enterprisedb.com), I had few observations
whichare summarized below:<p class="MsoNormal"> <p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial","sans-serif"">1.Function header for following functions still contains
refereceto log, seg</span><br /><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">   a.
InstallXLogFileSegment()</span><br/><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">   b.
RemoveOldXlogFiles()</span><br/><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">   c. XLogFileCopy()
</span><br/><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">   d. XLogGetLastRemoved()</span><br
/><spanstyle="font-size:10.0pt;font-family:"Arial","sans-serif"">   e. UpdateLastRemovedPtr()</span><br /><span
style="font-size:10.0pt;font-family:"Arial","sans-serif"">  f. RemoveOldXlogFiles()</span><br /><br /><span
style="font-size:10.0pt;font-family:"Arial","sans-serif"">2.@@ -2680,8 +2645,8 @@ InstallXLogFileSegment(uint32 *log,
uint32*seg, char *tmppath,</span><br /><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">               
        LWLockRelease(ControlFileLock);</span><br /><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">   
            ereport(LOG,</span><br /><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">                 
              (errcode_for_file_access(),</span><br /><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">-
                               errmsg("could not link file \"%s\" to \"%s\" (initialization of log file %u, segment
%u):%m",</span><br /><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">-                                
              tmppath, path, *log, *seg)));</span><br /><span
style="font-size:10.0pt;font-family:"Arial","sans-serif"">+                                errmsg("could not link file
\"%s\"to \"%s\" (initialization of log file): %m",</span><br /><span
style="font-size:10.0pt;font-family:"Arial","sans-serif"">+                                               tmppath,
path)));</span><br/><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">   If Changed error message can
containlog file and segment number, it would be more clear. That should be easily</span><br /><span
style="font-size:10.0pt;font-family:"Arial","sans-serif"">  deducible from segment number.</span><br /><br /><span
style="font-size:10.0pt;font-family:"Arial","sans-serif"">3. </span> <span
style="font-size:10.0pt;font-family:"Arial","sans-serif"">-RemoveOldXlogFiles(uint32log, uint32 seg, XLogRecPtr
endptr)</span><br/><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">+RemoveOldXlogFiles(XLogSegNo segno,
XLogRecPtrendptr)</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"">.</span><br/><span
style="font-size:10.0pt;font-family:"Arial","sans-serif"">@@-4016,8 +3953,9 @@ retry:</span><br /><span
style="font-size:10.0pt;font-family:"Arial","sans-serif"">                        if (!(((XLogPageHeader)
readBuf)->xlp_info& XLP_FIRST_IS_CONTRECORD))</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"">                              
 ereport(emode_for_corrupt_record(emode,*RecPtr),</span><br /><span
style="font-size:10.0pt;font-family:"Arial","sans-serif"">-                                             
 (errmsg("thereis no contrecord flag in log file %u, segment %u, offset %u",</span><br /><span
style="font-size:10.0pt;font-family:"Arial","sans-serif"">-                                                           
  readId, readSeg, readOff)));</span><br /><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">+          
                                    (errmsg("there is no contrecord flag in log segment %s, offset %u",</span><br
/><spanstyle="font-size:10.0pt;font-family:"Arial","sans-serif"">+                                                    
          XLogFileNameP(curFileTLI, readSegNo),</span><br /><span
style="font-size:10.0pt;font-family:"Arial","sans-serif"">+                                                           
  readOff)));</span><br /><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">                             
  goto next_record_is_invalid;</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"">                       
 pageHeaderSize= XLogPageHeaderSize((XLogPageHeader) readBuf);</span><br /><span
style="font-size:10.0pt;font-family:"Arial","sans-serif"">@@-4025,10 +3963,13 @@ retry:</span><br /><span
style="font-size:10.0pt;font-family:"Arial","sans-serif"">                        if (contrecord->xl_rem_len == 0
||</span><br/><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">                               
 total_len!= (contrecord->xl_rem_len + gotlen))</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"">+                               char
fname[MAXFNAMELEN];</span><br/><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">+                      
        XLogFileName(fname, curFileTLI, readSegNo);</span><br /><span
style="font-size:10.0pt;font-family:"Arial","sans-serif"">                              
 ereport(emode_for_corrupt_record(emode,*RecPtr),</span><br /><span
style="font-size:10.0pt;font-family:"Arial","sans-serif"">-                                             
 (errmsg("invalidcontrecord length %u in log file %u, segment %u, offset %u",</span><br /><span
style="font-size:10.0pt;font-family:"Arial","sans-serif"">+                                             
 (errmsg("invalidcontrecord length %u in log segment %s, offset %u",</span><br /><span
style="font-size:10.0pt;font-family:"Arial","sans-serif"">                                                            
  contrecord->xl_rem_len,</span><br /><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">-            
                                                  readId, readSeg, readOff)));</span><br /><span
style="font-size:10.0pt;font-family:"Arial","sans-serif"">+                                                           
  XLogFileNameP(curFileTLI, readSegNo),</span><br /><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">+  
                                                            readOff)));</span><br /><span
style="font-size:10.0pt;font-family:"Arial","sans-serif"">                                goto
next_record_is_invalid;</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""> For the above 2 changed error messages, 'log segment' is
usedfor filename. </span><br /><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">  However all similar
changeshas 'log file' for filename. There are some places</span><br /><span
style="font-size:10.0pt;font-family:"Arial","sans-serif""> where 'log segment' is used and other places it is 'log
file'.</span><br /><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">  So is there any particular reason
forit?</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"">4.</span><span
style="font-size:10.0pt;font-family:"Arial","sans-serif"">@@-533,33 +533,17 @@
pg_xlog_location_diff(PG_FUNCTION_ARGS)</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"">-         * Sanity check</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"">-       if (loc1.xrecoff > XLogFileSize)</span><br /><span
style="font-size:10.0pt;font-family:"Arial","sans-serif"">-               ereport(ERROR,</span><br /><span
style="font-size:10.0pt;font-family:"Arial","sans-serif"">-                             
 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),</span><br/><span
style="font-size:10.0pt;font-family:"Arial","sans-serif"">-                                errmsg("xrecoff \"%X\" is
outof valid range, 0..%X", loc1.xrecoff, XLogFileSize)));</span><br /><span
style="font-size:10.0pt;font-family:"Arial","sans-serif"">-       if (loc2.xrecoff > XLogFileSize)</span><br /><span
style="font-size:10.0pt;font-family:"Arial","sans-serif"">-               ereport(ERROR,</span><br /><span
style="font-size:10.0pt;font-family:"Arial","sans-serif"">-                             
 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),</span><br/><span
style="font-size:10.0pt;font-family:"Arial","sans-serif"">-                                errmsg("xrecoff \"%X\" is
outof valid range, 0..%X", loc2.xrecoff, XLogFileSize)));</span><br /><span
style="font-size:10.0pt;font-family:"Arial","sans-serif"">+       bytes1 = (((uint64)loc1.xlogid) << 32L) +
loc1.xrecoff;</span><br/><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">+        bytes2 =
(((uint64)loc2.xlogid)<< 32L) + loc2.xrecoff;</span><br /><br /><span
style="font-size:10.0pt;font-family:"Arial","sans-serif"">   Is there no chance that it can be out of valid range after
newchanges, just a doubt?</span><br /><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">    </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"">5.</span><br/><span
style="font-size:10.0pt;font-family:"Arial","sans-serif"">---a/src/backend/replication/walreceiver.c</span><br /><span
style="font-size:10.0pt;font-family:"Arial","sans-serif"">+++b/src/backend/replication/walreceiver.c</span><br /><span
style="font-size:10.0pt;font-family:"Arial","sans-serif"">@@-69,11 +69,12 @@ walrcv_disconnect_type walrcv_disconnect =
NULL;</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""> * These variables are used similarly to
openLogFile/Id/Seg/Off,</span><br/><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">- * but for
walreceiverto write the XLOG.</span><br /><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">+ * but for
walreceiverto write the XLOG. recvFileTLI is the TimeLineID</span><br /><br /><span
style="font-size:10.0pt;font-family:"Arial","sans-serif"">Inthe above comments, there is still reference to
Id/Seg/Off.</span><pclass="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif""> </span><p
class="MsoNormal"><spanstyle="font-size:10.0pt;font-family:"Arial","sans-serif""> </span><p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial","sans-serif"">WithRegards,</span><p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial","sans-serif"">AmitKapila.</span><p class="MsoNormal"> </div> 

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Reporting hba lines
Next
From: Tom Lane
Date:
Subject: Re: Posix Shared Mem patch