<HTML><BODY>Remove redundancy (second check)<br>Decided not to rename in xdir_scan() as it checks only header, but not data rows.<br><br><br><blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;">
        Среда, 31 января 2018, 17:05 +03:00 от Konstantin Belyavskiy <k.belyavskiy@tarantool.org>:<br>
        <br>
        <div id="">




























<div class="js-helper js-readmsg-msg">
        <style type="text/css"></style>
        <div>
                <base target="_self" href="https://e.mail.ru/">
                
            <div id="style_15174075440000000990_BODY"><div class="class_1517436705">
<br><blockquote style="border-left:1px solid #0857A6;margin:10px;padding:0 0 0 10px;"><div id=""><div class="js-helper_mailru_css_attribute_postfix js-readmsg-msg_mailru_css_attribute_postfix"><div><div id="style_15174047130000000195_BODY_mailru_css_attribute_postfix">
<br>
>  <br>
>  /*<br>
>   * Recovery subsystem<br>
> @@ -330,20 +332,26 @@ recovery_finalize(struct recovery *r, struct xstream *stream)<br>
>    recovery_close_log(r);<br>
>  <br>
>    /*<br>
> -   * Check that the last xlog file has rows.<br>
> +   * Rename last corrupted xlog if any. Cases:<br>
> +   *  - file has corrupted rows<br>
> +   *  - file has corrupted header<br>
> +   *  - file has zero size<br>
>     */<br>
> -  if (vclockset_last(&r->wal_dir.index) != NULL &&<br>
> -      vclock_sum(&r->vclock) ==<br>
> -      vclock_sum(vclockset_last(&r->wal_dir.index))) {<br>
> -          /*<br>
> -           * Delete the last empty xlog file.<br>
> -           */<br>
> +  if (vclockset_last(&r->wal_dir.index) != NULL) {<br>
>            char *name = xdir_format_filename(&r->wal_dir,<br>
>                                              vclock_sum(&r->vclock),<br>
>                                              NONE);<br>
> -          if (unlink(name) != 0) {<br>
> -                  tnt_raise(SystemError, "%s: failed to unlink file",<br>
> -                            name);<br>
> +          if (access(name, F_OK) == 0 ||<br>
<br>
> +              vclock_sum(&r->vclock) ==<br>
> +              vclock_sum(vclockset_last(&r->wal_dir.index))) {<br>
<br>
If there's an xlog file corresponding to r->vclock in r->wal_dir.index,<br>
it must exist, i.e. access() must return 0 for it. That said, the second<br>
check looks redundant.<br>
<br>
Come to think of it, we have scanned the whole xlog directory in<br>
xdir_scan() by the time we get here so using access() here looks<br>
strange. Can we call rename() right from xdir_scan() for files that<br>
we failed to index (corrupted header, empty)?<br>
<br></div></div></div></div></blockquote>
If xlog has corrupted data but header is OK, when second check<br>vclock_sum(&r->vclock) == vclock_sum(vclockset_last(&r->wal_dir.index))<br><br>But should we rename on xdir_scan() ? Good question BTW..<br>Roman, Konstantin, what do you think?<br><br><br>С уважением,<br>Konstantin Belyavskiy<br><a href="mailto:k.belyavskiy@tarantool.org">k.belyavskiy@tarantool.org</a><br><style></style>
</div></div>
            
        
                <base target="_self" href="https://e.mail.ru/">
        </div>

        
</div>


</div>
</blockquote>
<br>
<br>С уважением,<br>Konstantin Belyavskiy<br>k.belyavskiy@tarantool.org<br></BODY></HTML>