<div>Also wanted to clarify that both the rsync calls in the script are run to completion (not in the background) and there is a delay of 180 seconds between the two calls.<div><br></div><div>when the issue is seen the logs in the email below show the rsync messages from the two rsync calls are interleaved.</div>

<div><br></div><div>regards,</div><div>Alistair</div><br><div class="gmail_quote">On Thu, Apr 21, 2011 at 1:14 AM, Alistair Dsouza <span dir="ltr"><<a href="mailto:alistaird@gmail.com" target="_blank">alistaird@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<div><br></div><div>I am using rsync version 3.0.7 on an arm linux based embedded device. The device pulls data periodically from a rsync server and stores the files on an SD card.</div><div>The partial, temp and final rsync destinations all reside on the SD card.</div>



<div><br></div><div>I came across an issue where it seems that the rsync call returned with a success but the files that it pulled are not</div><div>moved immediately to its final destination. The issue points either to rsync not moving data immediately to its final location</div>



<div>of some delay in the virtual file system. However a read system call would flush the block buffer via the VFS.</div><div><br></div><div>I have a script which periodically calls the rsync client to check if data is available on a server located on a cloud.</div>



<div>The script contains two separate rsync calls. The first checks periodically if a file of a particular name is present. </div><div>The script has logic to know which file name is should be searching for next. Basically the file name has a number </div>



<div>in the name and this rysc calls periodically checks for that file. </div><div><br></div><div>The file pulled by the first rsync call contains info on the data (multiple files contained under a parent directory) that has to </div>



<div>be pulled from the server. The second rsync call comes into play when the first rsync call succeeds in pulling the file.</div><div>When the second rsync call returns with success the name of the file that has to be pulled by the first call is updated and</div>



<div>the cycle continues. In case either of the rsync calls fail, the script starts with the first rsync call.</div><div><br></div><div><snippet of the script></div><div><div>while :</div><div>do</div><div>    # get the name of the command file to pull next.</div>



<div>    CURR_Q_NUM=get_counter</div><div>    REMOTE_Q_FILE="${CURR_Q_NUM}.txt"</div><div>    LOCAL_Q_FILE="${Q_FOLDER}/${CURR_Q_NUM}.txt"</div><div><br></div><div>    # update the source and destination for rsync client</div>



<div>    SRC=$OPT_RSYNC_USER_NAME@$OPT_RSYNC_DEV_NAME::$RSYNC_Q_MODULE/$REMOTE_Q_FILE </div><div>    DEST=$LOCAL_Q_FILE </div><div><br></div><div>    rsync --update                 \</div><div>          --verbose                \</div>



<div>          --stats                  \</div><div>          --port=$OPT_RSYNC_PORT   \</div><div>          --partial-dir=$PARTIAL_XFER_FOLDER    \</div><div>          --temp-dir=$TEMP_FOLDER       \</div><div>          --bwlimit $CONFIG_PULL_RATE<span style="white-space:pre-wrap">       </span>\</div>



<div>          --timeout $CONFIG_TIMEOUT<span style="white-space:pre-wrap">       </span>\</div><div>          --contimeout $CONFIG_TIMEOUT<span style="white-space:pre-wrap">  </span>\</div><div>
          $SRC $DEST 1>>$RSYNC_LOG 2>&1</div><div><br></div><div>    if [ $? -eq 0 ]; then</div><div>        process_command_file   <<<< if the file was pulled completely then pull the files mentioned in this file.</div>



<div>        [ $? -eq 0 ] && { update_counter; }   <<<< update_counter increments the file name to the next file we should be looking for if all the data was all pulled correctly</div><div>    fi</div>



<div><br></div><div>    sleep $CONFIG_POLL_PERIOD   <<<<< this was configured as 180 seconds.</div><div>done</div></div><div><br></div><div><div>function process_command_file</div><div>{</div></div><div><div>



        # extract the source and destination from the file pulled by te rsync call in the while loop.</div><div>        SRC= ....</div><div>        DEST= .....</div><div><br></div><div>        rsync --update                              \</div>



<div>              --verbose                             \</div><div>              --stats                               \</div><div>              --port=$OPT_RSYNC_PORT                \</div><div>              --partial-dir=$PARTIAL_XFER_FOLDER    \</div>



<div>              --temp-dir=$TEMP_FOLDER               \</div><div>              --recursive                           \</div><div>              --bwlimit $CONFIG_PULL_RATE           \</div><div>              --timeout $CONFIG_TIMEOUT             \</div>



<div>              --contimeout $CONFIG_TIMEOUT          \</div><div>              $SRC $DEST 1>>$RSYNC_LOG 2>&1</div><div><br></div><div>        local RET=$?</div><div><br></div><div>        if [ "$RET" -eq 0 ]</div>



<div>        then</div><div><br></div><div>           # if the second rsync call succeeds then process the data</div><div>           FILES=$DEST/*</div><div><br></div><div>           for file in $FILES</div><div>           do</div>



<div>              # do some processing on the files  <b><<<<< for some reason in one instance the files were not present immediately in the final location even though rsync pulled the files and returned with success.</b></div>



<div>           done</div><div>        fi</div></div><div><br></div><div>     return $RET</div><div>}</div><div><b><snippet end></b></div><div><br></div><div>I noticed that the data is pulled by the second rsync call (in process_command_file) but when the script tries to process the data (just one instance was seen) it did not find it in its final location.</div>



<div><br></div><div>in this instance when the data was not processed (in the if condition in the process_command_file function) the rsync logs shows the data pulled successfully by both rsync calls but some of the logs of the second rsync call appear after the logs on the next rsync call in the cycle.</div>



<div><br></div><div><b><snippet of rsync logs when the issue is seen></b></div><div><br></div><div>0000000328.txt                    <b><span style="font-weight:normal"> <b><<<<< corresponding to the rsync call in the while loop the</b></span> command file is pulled</b></div>



<div><div><br></div><div>Number of files: 1</div><div>Number of files transferred: 1</div><div>Total file size: 108 bytes</div><div>Total transferred file size: 108 bytes</div><div>Literal data: 108 bytes</div><div>Matched data: 0 bytes</div>



<div>File list size: 28</div><div>File list generation time: 0.001 seconds</div><div>File list transfer time: 0.000 seconds</div><div>Total bytes sent: 53</div><div>Total bytes received: 213</div><div><br></div><div>sent 53 bytes  received 213 bytes  76.00 bytes/sec</div>



<div>total size is 108  speedup is 0.41</div><div><br></div><div><br></div><div>receiving incremental file list      <b><<<<<<< corresponding to the rsync call in process_command_file function</b></div>



<div>data/</div><div>data/LGC130UB.zip</div><div><br></div><div>rsync: link_stat "/0000000329.txt" (in q) failed: No such file or directory (2)  <b><<<<< corresponding to the rsync call in the while loop</b></div>



<div><b> <<<<<< since 0000000329.txt is not yet present on the server the script will loop on the rsync call in the while loop till it finds 000000329.txt</b></div><div><br></div><div>Number of files: 0</div>



<div>Number of files transferred: 0</div><div>Total file size: 0 bytes</div><div>Total transferred file size: 0 bytes</div><div>Literal data: 0 bytes</div><div>Matched data: 0 bytes</div><div>File list size: 3</div><div>


Total bytes sent: 15</div>
<div>Total bytes received: 8</div><div><br></div><div>sent 15 bytes  received 8 bytes  9.20 bytes/sec</div><div>total size is 0  speedup is 0.00</div><div>rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1508) [Receiver=3.0.7]</div>



<div><br></div><div>meta/       <b><<<<<<< corresponding to the rsync call in process_command_file function which should have occurred before the rsync call above it</b></div><div><br></div><div>Number of files: 3   <b><<<<< 3 corresponds to data, data/LGC130UB.zip, meta</b></div>



<div>Number of files transferred: 1</div><div>Total file size: 15284642 bytes</div><div>Total transferred file size: 15284642 bytes</div><div>Literal data: 15284642 bytes</div><div>Matched data: 0 bytes</div><div>File list size: 56</div>



<div>File list generation time: 0.001 seconds</div><div>File list transfer time: 0.000 seconds</div><div>Total bytes sent: 68</div><div>Total bytes received: 15286657</div><div><br></div><div>sent 68 bytes  received 15286657 bytes  87103.85 bytes/sec</div>



<div>total size is 15284642  speedup is 1.00</div><div><br></div><div>rsync: link_stat "/0000000329.txt" (in q) failed: No such file or directory (2)   <b><<<<< corresponding to the rsync call in the while loop</b></div>



<div><br></div><div>Number of files: 0</div><div>Number of files transferred: 0</div><div>Total file size: 0 bytes</div><div>Total transferred file size: 0 bytes</div><div>Literal data: 0 bytes</div><div>Matched data: 0 bytes</div>



<div>File list size: 3</div><div>Total bytes sent: 15</div><div>Total bytes received: 8</div><div><br></div><div>sent 15 bytes  received 8 bytes  5.11 bytes/sec</div><div>total size is 0  speedup is 0.00</div></div><div>


<b><end of snippet></b></div>
<div><b><br></b></div><div><b><br></b></div><div><b><snippet of rsync logs when everything works fine></b></div><div><div>rsync: link_stat "/0000000330.txt" (in q) failed: No such file or directory (2) <b><<<<< corresponding to the rsync call in the while loop</b></div>



<div><br></div><div>Number of files: 0</div><div>Number of files transferred: 0</div><div>Total file size: 0 bytes</div><div>Total transferred file size: 0 bytes</div><div>Literal data: 0 bytes</div><div>Matched data: 0 bytes</div>



<div>File list size: 3</div><div>Total bytes sent: 15</div><div>Total bytes received: 8</div><div><br></div><div>sent 15 bytes  received 8 bytes  9.20 bytes/sec</div><div>total size is 0  speedup is 0.00</div><div>rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1508) [Receiver=3.0.7]</div>



<div><br></div><div>rsync: link_stat "/0000000330.txt" (in q) failed: No such file or directory (2) <b><<<<< corresponding to the rsync call in the while loop</b></div><div><br></div><div>Number of files: 0</div>



<div>Number of files transferred: 0</div><div>Total file size: 0 bytes</div><div>Total transferred file size: 0 bytes</div><div>Literal data: 0 bytes</div><div>Matched data: 0 bytes</div><div>File list size: 3</div><div>


Total bytes sent: 15</div>
<div>Total bytes received: 8</div><div><br></div><div>sent 15 bytes  received 8 bytes  6.57 bytes/sec</div><div>total size is 0  speedup is 0.00</div><div>rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1508) [Receiver=3.0.7]</div>



<div><br></div><div>0000000330.txt <b><<<<< corresponding to the rsync call in the while loop. we can now process the contents of this file and pull the data.</b></div><div><br></div><div>Number of files: 1</div>



<div>Number of files transferred: 1</div><div>Total file size: 108 bytes</div><div>Total transferred file size: 108 bytes</div><div>Literal data: 108 bytes</div><div>Matched data: 0 bytes</div><div>File list size: 28</div>



<div>File list generation time: 0.001 seconds</div><div>File list transfer time: 0.000 seconds</div><div>Total bytes sent: 53</div><div>Total bytes received: 213</div><div><br></div><div>sent 53 bytes  received 213 bytes  59.11 bytes/sec</div>



<div>total size is 108  speedup is 0.41</div><div><br></div><div>receiving incremental file list  <b><<<<<<< corresponding to the rsync call in process_command_file function</b></div><div>data/</div>


<div>
data/MDL130UB.zip</div><div>meta/</div><div><br></div><div>Number of files: 3   <b><<<<< 3 corresponds to data, data/MDL130UB.zip, meta</b></div><div>Number of files transferred: 1</div><div>Total file size: 13810445 bytes</div>



<div>Total transferred file size: 13810445 bytes</div><div>Literal data: 13810445 bytes</div><div>Matched data: 0 bytes</div><div>File list size: 60</div><div>File list generation time: 0.001 seconds</div><div>File list transfer time: 0.000 seconds</div>



<div>Total bytes sent: 68</div><div>Total bytes received: 13812284</div><div><br></div><div>sent 68 bytes  received 13812284 bytes  91776.43 bytes/sec</div><div>total size is 13810445  speedup is 1.00</div><div><br></div>



<div>rsync: link_stat "/0000000331.txt" (in q) failed: No such file or directory (2)  <b><<<<< corresponding to the rsync call in the while loop</b></div><div><br></div><div>Number of files: 0</div>



<div>Number of files transferred: 0</div><div>Total file size: 0 bytes</div><div>Total transferred file size: 0 bytes</div><div>Literal data: 0 bytes</div><div>Matched data: 0 bytes</div><div>File list size: 3</div><div>


Total bytes sent: 15</div>
<div>Total bytes received: 8</div><div><br></div><div>sent 15 bytes  received 8 bytes  9.20 bytes/sec</div><div>total size is 0  speedup is 0.00</div><div>rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1508) [Receiver=3.0.7]</div>



<div><br></div><div>rsync: link_stat "/0000000331.txt" (in q) failed: No such file or directory (2)  <b><<<<< corresponding to the rsync call in the while loop</b></div><div><br></div><div>Number of files: 0</div>



<div>Number of files transferred: 0</div><div>Total file size: 0 bytes</div><div>Total transferred file size: 0 bytes</div><div>Literal data: 0 bytes</div><div>Matched data: 0 bytes</div><div>File list size: 3</div><div>


Total bytes sent: 15</div>
<div>Total bytes received: 8</div><div><br></div><div>sent 15 bytes  received 8 bytes  6.57 bytes/sec</div><div>total size is 0  speedup is 0.00</div><div>rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1508) [Receiver=3.0.7]</div>



</div><div><b><end of snippet></b></div><div><br></div><div>thanks,</div><div>Alistair</div>
</blockquote></div><br></div>