From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> To: tarantool-patches@dev.tarantool.org, gorcunov@gmail.com Subject: [Tarantool-patches] [PATCH 1/1] txn_limbo: reduce fiber_set_cancellable() calls Date: Thu, 30 Jul 2020 01:41:20 +0200 [thread overview] Message-ID: <a6ab37710e81ff1fe51efa897631aee7c0efc506.1596066060.git.v.shpilevoy@tarantool.org> (raw) The calls were added before and after each cond_wait() so as the fiber couldn't be woken up externally. For example, from Lua. But it is not necessary to flip the flag on each wait() call. It is enough to make it 2 times: forbid cancellation in the beginning of txn_limbo_wait_complete(), and return the old value back in the end. --- Branch: http://github.com/tarantool/tarantool/tree/gerold103/qsync-fiber_set_cancellable-refactor src/box/txn_limbo.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/box/txn_limbo.c b/src/box/txn_limbo.c index b6725ae21..7f43e1c0c 100644 --- a/src/box/txn_limbo.c +++ b/src/box/txn_limbo.c @@ -185,6 +185,8 @@ int txn_limbo_wait_complete(struct txn_limbo *limbo, struct txn_limbo_entry *entry) { assert(entry->lsn > 0 || !txn_has_flag(entry->txn, TXN_WAIT_ACK)); + bool cancellable = fiber_set_cancellable(false); + if (txn_limbo_entry_is_complete(entry)) goto complete; @@ -193,10 +195,8 @@ txn_limbo_wait_complete(struct txn_limbo *limbo, struct txn_limbo_entry *entry) double start_time = fiber_clock(); while (true) { double deadline = start_time + replication_synchro_timeout; - bool cancellable = fiber_set_cancellable(false); double timeout = deadline - fiber_clock(); int rc = fiber_cond_wait_timeout(&limbo->wait_cond, timeout); - fiber_set_cancellable(cancellable); if (txn_limbo_entry_is_complete(entry)) goto complete; if (rc != 0) @@ -215,11 +215,9 @@ do_rollback: * rollback. Wait when it will finish and wake us * up. */ - bool cancellable = fiber_set_cancellable(false); do { fiber_yield(); } while (!txn_limbo_entry_is_complete(entry)); - fiber_set_cancellable(cancellable); goto complete; } @@ -236,6 +234,7 @@ do_rollback: break; fiber_wakeup(e->txn->fiber); } + fiber_set_cancellable(cancellable); diag_set(ClientError, ER_SYNC_QUORUM_TIMEOUT); return -1; @@ -247,6 +246,7 @@ complete: */ assert(rlist_empty(&entry->in_queue)); assert(txn_has_flag(entry->txn, TXN_IS_DONE)); + fiber_set_cancellable(cancellable); /* * The first tx to be rolled back already performed all * the necessary cleanups for us. -- 2.21.1 (Apple Git-122.3)
next reply other threads:[~2020-07-29 23:41 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-07-29 23:41 Vladislav Shpilevoy [this message] 2020-07-30 8:47 ` Cyrill Gorcunov 2020-07-30 19:57 ` Vladislav Shpilevoy
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=a6ab37710e81ff1fe51efa897631aee7c0efc506.1596066060.git.v.shpilevoy@tarantool.org \ --to=v.shpilevoy@tarantool.org \ --cc=gorcunov@gmail.com \ --cc=tarantool-patches@dev.tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH 1/1] txn_limbo: reduce fiber_set_cancellable() calls' \ /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