From: Serge Petrenko <sergepetrenko@tarantool.org> To: v.shpilevoy@tarantool.org, sergos@tarantool.org, gorcunov@tarantool.org, lvasiliev@tarantool.org Cc: tarantool-patches@dev.tarantool.org Subject: [Tarantool-patches] [PATCH 1/2] box: rework local_recovery to use async txn_commit Date: Fri, 19 Jun 2020 21:00:14 +0300 [thread overview] Message-ID: <46ed0cc08e6ecf7ee7c9250d9cdfc3d68aa5c764.1592589312.git.sergepetrenko@tarantool.org> (raw) In-Reply-To: <cover.1592589312.git.sergepetrenko@tarantool.org> Local recovery should use asynchronous txn commit procedure in order to get to CONFIRM and ROLLBACK statements for a transaction that needs confirmation before confirmation timeout happens. Using async txn commit doesn't harm other transactions, since the journal used during local recovery fakes writes and its write_async() method may reuse plain write(). Follow-up #4847 Follow-up #4848 --- src/box/box.cc | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/src/box/box.cc b/src/box/box.cc index 8ba7ffafb..f80d6f8e6 100644 --- a/src/box/box.cc +++ b/src/box/box.cc @@ -118,6 +118,8 @@ static struct gc_checkpoint_ref backup_gc; static bool is_box_configured = false; static bool is_ro = true; static fiber_cond ro_cond; +/** Set to true during recovery from local files. */ +static bool is_local_recovery = false; /** * The following flag is set if the instance failed to @@ -206,7 +208,24 @@ box_process_rw(struct request *request, struct space *space, goto rollback; if (is_autocommit) { - if (txn_commit(txn) != 0) + int res = 0; + /* + * During local recovery the commit procedure + * should be async, otherwise the only fiber + * processing recovery will get stuck on the first + * synchronous tx it meets until confirm timeout + * is reached and the tx is rolled back, yielding + * an error. + * Moreover, txn_commit_async() doesn't hurt at + * all during local recovery, since journal_write + * is faked at this stage and returns immediately. + */ + if (is_local_recovery) { + res = txn_commit_async(txn); + } else { + res = txn_commit(txn); + } + if (res < 0) goto error; fiber_gc(); } @@ -327,12 +346,25 @@ recovery_journal_write(struct journal *base, return 0; } +static int +recovery_journal_write_async(struct journal *base, + struct journal_entry *entry) +{ + recovery_journal_write(base, entry); + /* + * Since there're no actual writes, fire a + * journal_async_complete callback right away. + */ + journal_async_complete(base, entry); + return 0; +} + static void recovery_journal_create(struct vclock *v) { static struct recovery_journal journal; - journal_create(&journal.base, journal_no_write_async, - journal_no_write_async_cb, + journal_create(&journal.base, recovery_journal_write_async, + txn_complete_async, recovery_journal_write, NULL); journal.vclock = v; journal_set(&journal.base); @@ -2315,6 +2347,7 @@ local_recovery(const struct tt_uuid *instance_uuid, memtx = (struct memtx_engine *)engine_by_name("memtx"); assert(memtx != NULL); + is_local_recovery = true; recovery_journal_create(&recovery->vclock); /* @@ -2356,6 +2389,7 @@ local_recovery(const struct tt_uuid *instance_uuid, box_sync_replication(false); } recovery_finalize(recovery); + is_local_recovery = false; /* * We must enable WAL before finalizing engine recovery, -- 2.24.3 (Apple Git-128)
next prev parent reply other threads:[~2020-06-19 18:00 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-06-19 18:00 [Tarantool-patches] [PATCH 0/2] replication: support CONFIRM and ROLLBACK in recovery Serge Petrenko 2020-06-19 18:00 ` Serge Petrenko [this message] 2020-06-19 18:45 ` [Tarantool-patches] [PATCH 1/2] box: rework local_recovery to use async txn_commit Serge Petrenko 2020-06-21 16:25 ` Vladislav Shpilevoy 2020-06-22 11:19 ` Serge Petrenko 2020-06-22 18:55 ` Serge Petrenko 2020-06-22 21:43 ` Vladislav Shpilevoy 2020-06-23 8:39 ` Serge Petrenko 2020-06-26 22:00 ` Vladislav Shpilevoy 2020-06-19 18:00 ` [Tarantool-patches] [PATCH 2/2] replication: support ROLLBACK and CONFIRM during recovery Serge Petrenko 2020-06-23 11:50 ` Serge Petrenko
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=46ed0cc08e6ecf7ee7c9250d9cdfc3d68aa5c764.1592589312.git.sergepetrenko@tarantool.org \ --to=sergepetrenko@tarantool.org \ --cc=gorcunov@tarantool.org \ --cc=lvasiliev@tarantool.org \ --cc=sergos@tarantool.org \ --cc=tarantool-patches@dev.tarantool.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH 1/2] box: rework local_recovery to use async txn_commit' \ /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