From: Vladislav Shpilevoy via Tarantool-patches <tarantool-patches@dev.tarantool.org> To: tarantool-patches@dev.tarantool.org, gorcunov@gmail.com, sergepetrenko@tarantool.org Subject: [Tarantool-patches] [PATCH 04/13] wal: refactor wal_write_to_disk() Date: Fri, 11 Jun 2021 23:56:12 +0200 [thread overview] Message-ID: <acd9e680dbe894c570413c395ea49b611821f5d5.1623448465.git.v.shpilevoy@tarantool.org> (raw) In-Reply-To: <cover.1623448465.git.v.shpilevoy@tarantool.org> It didn't have a single fail path. That led to some amount of code duplication, and it complicated future patches where the journal entries are going to get a proper error reason instead of default -1 without any details. The patch is a preparation for #6027 where it is wanted to have more detailed errors on journal entry/transaction fail instead of ER_WAL_IO for everything. Sometimes it can override a real error like a cascade rollback, or a transaction conflict. Part of #6027 --- src/box/wal.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/box/wal.c b/src/box/wal.c index 25edbace6..40382e791 100644 --- a/src/box/wal.c +++ b/src/box/wal.c @@ -863,10 +863,8 @@ wal_opt_rotate(struct wal_writer *writer) return 0; if (xdir_create_xlog(&writer->wal_dir, &writer->current_wal, - &writer->vclock) != 0) { - diag_log(); + &writer->vclock) != 0) return -1; - } /* * Keep track of the new WAL vclock. Required for garbage * collection, see wal_collect_garbage(). @@ -1038,7 +1036,10 @@ wal_write_to_disk(struct cmsg *msg) { struct wal_writer *writer = &wal_writer_singleton; struct wal_msg *wal_msg = (struct wal_msg *) msg; + struct stailq_entry *last_committed = NULL; + struct journal_entry *entry; struct error *error; + assert(!stailq_empty(&wal_msg->commit)); /* * Track all vclock changes made by this batch into @@ -1058,23 +1059,17 @@ wal_write_to_disk(struct cmsg *msg) if (writer->is_in_rollback) { /* We're rolling back a failed write. */ - stailq_concat(&wal_msg->rollback, &wal_msg->commit); - vclock_copy(&wal_msg->vclock, &writer->vclock); - return; + goto done; } /* Xlog is only rotated between queue processing */ if (wal_opt_rotate(writer) != 0) { - stailq_concat(&wal_msg->rollback, &wal_msg->commit); - vclock_copy(&wal_msg->vclock, &writer->vclock); - return wal_begin_rollback(); + goto done; } /* Ensure there's enough disk space before writing anything. */ if (wal_fallocate(writer, wal_msg->approx_len) != 0) { - stailq_concat(&wal_msg->rollback, &wal_msg->commit); - vclock_copy(&wal_msg->vclock, &writer->vclock); - return wal_begin_rollback(); + goto done; } /* @@ -1104,8 +1099,6 @@ wal_write_to_disk(struct cmsg *msg) * Iterate over requests (transactions) */ int rc; - struct journal_entry *entry; - struct stailq_entry *last_committed = NULL; stailq_foreach_entry(entry, &wal_msg->commit, fifo) { wal_assign_lsn(&vclock_diff, &writer->vclock, entry); entry->res = vclock_sum(&vclock_diff) + -- 2.24.3 (Apple Git-128)
next prev parent reply other threads:[~2021-06-11 22:00 UTC|newest] Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-06-11 21:56 [Tarantool-patches] [PATCH 00/13] Applier rollback reason Vladislav Shpilevoy via Tarantool-patches 2021-06-11 21:56 ` [Tarantool-patches] [PATCH 01/13] error: introduce ER_CASCADE_ROLLBACK Vladislav Shpilevoy via Tarantool-patches 2021-06-11 21:56 ` [Tarantool-patches] [PATCH 10/13] txn: install proper diag errors on txn fail Vladislav Shpilevoy via Tarantool-patches 2021-06-11 21:56 ` [Tarantool-patches] [PATCH 11/13] wal: introduce JOURNAL_ENTRY_ERR_CASCADE Vladislav Shpilevoy via Tarantool-patches 2021-06-11 21:56 ` [Tarantool-patches] [PATCH 12/13] txn: introduce TXN_SIGNATURE_ABORT Vladislav Shpilevoy via Tarantool-patches 2021-06-11 21:56 ` [Tarantool-patches] [PATCH 13/13] txn: stop TXN_SIGNATURE_ABORT override Vladislav Shpilevoy via Tarantool-patches 2021-06-15 13:44 ` Serge Petrenko via Tarantool-patches 2021-06-15 19:34 ` Vladislav Shpilevoy via Tarantool-patches 2021-06-11 21:56 ` [Tarantool-patches] [PATCH 02/13] test: remove replica-applier-rollback.lua Vladislav Shpilevoy via Tarantool-patches 2021-06-11 21:56 ` [Tarantool-patches] [PATCH 03/13] journal: make journal_write() set diag on error Vladislav Shpilevoy via Tarantool-patches 2021-06-11 21:56 ` Vladislav Shpilevoy via Tarantool-patches [this message] 2021-06-15 20:46 ` [Tarantool-patches] [PATCH 04/13] wal: refactor wal_write_to_disk() Cyrill Gorcunov via Tarantool-patches 2021-06-16 6:22 ` Vladislav Shpilevoy via Tarantool-patches 2021-06-16 8:02 ` Cyrill Gorcunov via Tarantool-patches 2021-06-16 23:32 ` Vladislav Shpilevoy via Tarantool-patches 2021-06-11 21:56 ` [Tarantool-patches] [PATCH 05/13] diag: introduce diag_set_detailed() Vladislav Shpilevoy via Tarantool-patches 2021-06-11 21:56 ` [Tarantool-patches] [PATCH 06/13] wal: encapsulate ER_WAL_IO Vladislav Shpilevoy via Tarantool-patches 2021-06-11 21:56 ` [Tarantool-patches] [PATCH 07/13] txn: change limbo rollback check in the trigger Vladislav Shpilevoy via Tarantool-patches 2021-06-11 21:56 ` [Tarantool-patches] [PATCH 08/13] journal: introduce proper error codes Vladislav Shpilevoy via Tarantool-patches 2021-06-11 21:56 ` [Tarantool-patches] [PATCH 09/13] txn: assert after WAL write that txn is not done Vladislav Shpilevoy via Tarantool-patches 2021-06-15 13:43 ` [Tarantool-patches] [PATCH 00/13] Applier rollback reason Serge Petrenko via Tarantool-patches 2021-06-16 23:32 ` Vladislav Shpilevoy via Tarantool-patches
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=acd9e680dbe894c570413c395ea49b611821f5d5.1623448465.git.v.shpilevoy@tarantool.org \ --to=tarantool-patches@dev.tarantool.org \ --cc=gorcunov@gmail.com \ --cc=sergepetrenko@tarantool.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH 04/13] wal: refactor wal_write_to_disk()' \ /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