Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: tml <tarantool-patches@dev.tarantool.org>
Subject: Re: [Tarantool-patches] [PATCH v2 4/4] qsync: don't send negative timeouts into fiber_cond_wait_timeout
Date: Fri, 17 Jul 2020 00:45:16 +0200	[thread overview]
Message-ID: <c50046b5-59f2-2696-ce34-97aee98ad204@tarantool.org> (raw)
In-Reply-To: <20200714145358.GG296695@grain>

Thanks for the patch!

On 14.07.2020 16:53, Cyrill Gorcunov wrote:
> Basically our timeout is calculated via (a - b), where
> @a is a constant positive value fetched once, in turn
> the @b is rather a dynamic value thus the result may
> be negative. libev uses assert() call to catch such
> values when passed to timers setup. Thus lets intercept
> potential assert() trigger and exit early if timeout
> is already expired.
> 
> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
> ---
> There were a typo, so I force-updated the branch
> 
>  src/box/txn_limbo.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/src/box/txn_limbo.c b/src/box/txn_limbo.c
> index d5b887d36..0924952b7 100644
> --- a/src/box/txn_limbo.c
> +++ b/src/box/txn_limbo.c
> @@ -174,8 +174,10 @@ 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();
> +		if (timeout < 0)
> +			goto do_rollback;
> +		bool cancellable = fiber_set_cancellable(false);

I added timeout = -1; here and tried to commit a sync transaction. I
got timed out error, no assertions. Please, tell me, how to reproduce
the assertion you mention in the commit message. Otherwise I don't see
why would we need the < 0 check. If it is done somewhere inside
fiber_cond_wait_timeout anyway.

>  		int rc = fiber_cond_wait_timeout(&limbo->wait_cond, timeout);
>  		fiber_set_cancellable(cancellable);
>  		if (txn_limbo_entry_is_complete(entry))
> @@ -509,8 +511,10 @@ txn_limbo_wait_confirm(struct txn_limbo *limbo)
>  	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();
> +		if (timeout < 0)
> +			goto timed_out;
> +		bool cancellable = fiber_set_cancellable(false);
>  		int rc = fiber_cond_wait_timeout(&limbo->wait_cond, timeout);
>  		fiber_set_cancellable(cancellable);
>  		if (cwp.is_confirm || cwp.is_rollback)
> 

  reply	other threads:[~2020-07-16 22:45 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-14 14:44 [Tarantool-patches] [PATCH 0/4] qsync: continue cooking the code Cyrill Gorcunov
2020-07-14 14:44 ` [Tarantool-patches] [PATCH 1/4] qsync: add missing functions descriptions Cyrill Gorcunov
2020-07-14 14:44 ` [Tarantool-patches] [PATCH 2/4] qsync: drop txn_limbo_confirm_timeout Cyrill Gorcunov
2020-07-14 14:44 ` [Tarantool-patches] [PATCH 3/4] qsync: txn_limbo_wait_complete -- fix type conversion Cyrill Gorcunov
2020-07-14 14:44 ` [Tarantool-patches] [PATCH 4/4] qsync: don't send negative timeouts into fiber_cond_wait_timeout Cyrill Gorcunov
2020-07-14 14:53   ` [Tarantool-patches] [PATCH v2 " Cyrill Gorcunov
2020-07-16 22:45     ` Vladislav Shpilevoy [this message]
2020-07-17  7:25       ` Cyrill Gorcunov
2020-07-17 20:03         ` Vladislav Shpilevoy
2020-07-17 20:33           ` Cyrill Gorcunov
2020-07-17 20:43             ` Cyrill Gorcunov
2020-07-20 19:28 ` [Tarantool-patches] [PATCH 0/4] qsync: continue cooking the code 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=c50046b5-59f2-2696-ce34-97aee98ad204@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=gorcunov@gmail.com \
    --cc=tarantool-patches@dev.tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v2 4/4] qsync: don'\''t send negative timeouts into fiber_cond_wait_timeout' \
    /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