<HTML><BODY><br><blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;"><div id=""><div class="js-helper js-readmsg-msg"><div><div id="style_15174047130000000195_BODY">
<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>k.belyavskiy@tarantool.org<br><style type="text/css"></style></BODY></HTML>