From: Konstantin Osipov <kostja@tarantool.org> To: Vladimir Davydov <vdavydov.dev@gmail.com> Cc: tarantool-patches@freelists.org Subject: Re: [PATCH 3/3] wal: create empty xlog on shutdown Date: Wed, 27 Jun 2018 20:29:21 +0300 [thread overview] Message-ID: <20180627172921.GF28358@chai> (raw) In-Reply-To: <1499b12de12125f1258324b83e3fbb0e1d1d0587.1529075903.git.vdavydov.dev@gmail.com> * Vladimir Davydov <vdavydov.dev@gmail.com> [18/06/15 23:28]: > recovery_finalize(struct recovery *r) > { > recovery_close_log(r); > - > - /* > - * Check if next xlog exists. If it's true this xlog is > - * corrupted and we should rename it (to avoid getting > - * problem on the next xlog write with the same name). > - * Possible reasons are: > - * - last xlog has corrupted rows > - * - last xlog has corrupted header > - * - last xlog has zero size > - */ > - char *name = xdir_format_filename(&r->wal_dir, > - vclock_sum(&r->vclock), > - NONE); > - if (access(name, F_OK) == 0) { > - say_info("rename corrupted xlog %s", name); > - char to[PATH_MAX]; > - snprintf(to, sizeof(to), "%s.corrupted", name); > - if (rename(name, to) != 0) { > - tnt_raise(SystemError, > - "%s: can't rename corrupted xlog", > - name); > - } > - } I agree this hunk should be moved to wal.c, but I don't understand why it has to be done in wal thread. Please make it obvious by leaving only the necessary parts in wal_init_f and adding a comment. > --- a/src/box/wal.c > +++ b/src/box/wal.c > @@ -310,6 +310,39 @@ wal_thread_start() > cpipe_set_max_input(&wal_thread.wal_pipe, IOV_MAX); > } > > +static int > +wal_init_f(struct cbus_call_msg *msg) Please add a formal comment for this function. > /** > * Initialize WAL writer. > * > @@ -332,6 +365,11 @@ wal_init(enum wal_mode wal_mode, const char *wal_dirname, > if (xdir_scan(&writer->wal_dir)) > return -1; > > + struct cbus_call_msg msg; > + if (cbus_call(&wal_thread.wal_pipe, &wal_thread.tx_pipe, &msg, > + wal_init_f, NULL, TIMEOUT_INFINITY) != 0) > + return -1; > + > + /* > + * Create a new empty WAL on shutdown so that we don't have > + * to rescan the last WAL to find the instance vclock. > + */ > + if (writer->wal_mode != WAL_NONE && > + xdir_create_xlog(&writer->wal_dir, &writer->current_wal, > + &writer->vclock) == 0) > + xlog_close(&writer->current_wal, false); In case there is an existing empty xlog file, this function fails to create a new one and returns an error which you ignore. Please handle this case nicely and avoid trying to create a new xlog file if it is not necessary. > -- Konstantin Osipov, Moscow, Russia, +7 903 626 22 32 http://tarantool.io - www.twitter.com/kostja_osipov
next prev parent reply other threads:[~2018-06-27 17:29 UTC|newest] Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-06-08 17:34 [PATCH v2 00/11] Replica rejoin Vladimir Davydov 2018-06-08 17:34 ` [PATCH v2 01/11] box: retrieve instance uuid before starting local recovery Vladimir Davydov 2018-06-08 17:51 ` Konstantin Osipov 2018-06-08 17:34 ` [PATCH v2 02/11] box: refactor hot standby recovery Vladimir Davydov 2018-06-08 17:34 ` [PATCH v2 03/11] box: retrieve end vclock before starting local recovery Vladimir Davydov 2018-06-14 12:58 ` Konstantin Osipov 2018-06-08 17:34 ` [PATCH v2 04/11] box: open the port " Vladimir Davydov 2018-06-13 20:43 ` Konstantin Osipov 2018-06-14 8:31 ` Vladimir Davydov 2018-06-14 12:59 ` Konstantin Osipov 2018-06-15 15:48 ` [PATCH 0/3] Speed up recovery in case rebootstrap is not needed Vladimir Davydov 2018-06-15 15:48 ` [PATCH 1/3] xlog: erase eof marker when reopening existing file for writing Vladimir Davydov 2018-06-27 17:09 ` Konstantin Osipov 2018-06-15 15:48 ` [PATCH 2/3] wal: rollback vclock on write failure Vladimir Davydov 2018-06-27 17:22 ` Konstantin Osipov 2018-06-15 15:48 ` [PATCH 3/3] wal: create empty xlog on shutdown Vladimir Davydov 2018-06-27 17:29 ` Konstantin Osipov [this message] 2018-06-08 17:34 ` [PATCH v2 05/11] box: connect to remote peers before starting local recovery Vladimir Davydov 2018-06-13 20:45 ` Konstantin Osipov 2018-06-14 8:34 ` Vladimir Davydov 2018-06-14 12:59 ` Konstantin Osipov 2018-06-08 17:34 ` [PATCH v2 06/11] box: factor out local recovery function Vladimir Davydov 2018-06-13 20:50 ` Konstantin Osipov 2018-06-08 17:34 ` [PATCH v2 07/11] applier: inquire oldest vclock on connect Vladimir Davydov 2018-06-13 20:51 ` Konstantin Osipov 2018-06-14 8:40 ` Vladimir Davydov 2018-06-08 17:34 ` [PATCH v2 08/11] replication: rebootstrap instance on startup if it fell behind Vladimir Davydov 2018-06-13 20:55 ` Konstantin Osipov 2018-06-14 8:58 ` Vladimir Davydov 2018-06-08 17:34 ` [PATCH v2 09/11] vinyl: simplify vylog recovery from backup Vladimir Davydov 2018-06-08 17:34 ` [PATCH v2 10/11] vinyl: pass flags to vy_recovery_new Vladimir Davydov 2018-06-13 20:56 ` Konstantin Osipov 2018-06-08 17:34 ` [PATCH v2 11/11] vinyl: implement rebootstrap support Vladimir Davydov 2018-06-10 12:02 ` Vladimir Davydov
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20180627172921.GF28358@chai \ --to=kostja@tarantool.org \ --cc=tarantool-patches@freelists.org \ --cc=vdavydov.dev@gmail.com \ --subject='Re: [PATCH 3/3] wal: create empty xlog on shutdown' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox