Tarantool development patches archive
 help / color / mirror / Atom feed
From: Cyrill Gorcunov via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Serge Petrenko <sergepetrenko@tarantool.org>
Cc: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>,
	tml <tarantool-patches@dev.tarantool.org>
Subject: Re: [Tarantool-patches] [PATCH v27 2/3] qsync: order access to the limbo terms
Date: Tue, 11 Jan 2022 23:39:41 +0300	[thread overview]
Message-ID: <Yd3rDf460NT+KbvJ@grain> (raw)
In-Reply-To: <1641824923.419591282@f764.i.mail.ru>

On Mon, Jan 10, 2022 at 05:28:43PM +0300, Serge Petrenko wrote:
>    Hi! Thanks for the patch!
>     
>    box_issue_promote() and box_issue_demote() need fine-grained locking
>    anyway.
>    Otherwise it’s possible that promote() is already issued, but not yet
>    written to WAL, and some
>    outdated request is applied by applier at that exact moment.

True. And in previous series Vlad has asked to not move in code which is
not covered by tests. So I think this is a task for the next part. Currently
we cover only the race between appliers.

>     
>    You should take the lock before the WAL write, and release it only after
>    txn_limbo_apply.
>     
>    No need to guard every limbo function there is, but we have to guard
>    everything that
>    writes PROMOTE/DEMOTE.
...
>      @@ -216,7 +225,7 @@ txn_limbo_last_entry(struct txn_limbo *limbo)
>        * @a replica_id.
>        */
>       static inline uint64_t
>      -txn_limbo_replica_term(const struct txn_limbo *limbo, uint32_t
>      replica_id)
>      +txn_limbo_replica_term(struct txn_limbo *limbo, uint32_t replica_id)
>       {
> 
>     
>    You’ve forgot to lock the latch here, I guess.

I did it on a purpose. As you remember we've faced many problems when tried
to implement fine-grained locking inside limbo code. So I dropped this idea
eventually and I think we could start with explicit locks to cover the applier
race and then walk via small steps trying to cover the rest.

>      +/**
>      + * Initiate execution of a synchronous replication request.
>      + */
>      +static inline void
>      +txn_limbo_begin(struct txn_limbo *limbo)
>      +{
>      + limbo->promote_latch_cnt++;
>      + latch_lock(&limbo->promote_latch);
> 
>     
>    I suppose you should decrease the latch_cnt right after acquiring the
>    lock.
>     
>    Otherwise you count the sole «limbo user» together with «limbo waiters».

Yes, this will represent accumulated value. To be honest I never saw such
approach in any other code (ie increment/lock/decrement) but I think this
is fine for fibres, will do.

	Cyrill

  reply	other threads:[~2022-01-11 20:39 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-30 20:23 [Tarantool-patches] [PATCH v27 0/3] qsync: implement packet filtering (part 1) Cyrill Gorcunov via Tarantool-patches
2021-12-30 20:23 ` [Tarantool-patches] [PATCH v27 1/3] latch: add latch_is_locked helper Cyrill Gorcunov via Tarantool-patches
2021-12-30 20:23 ` [Tarantool-patches] [PATCH v27 2/3] qsync: order access to the limbo terms Cyrill Gorcunov via Tarantool-patches
2022-01-10 14:28   ` Serge Petrenko via Tarantool-patches
2022-01-11 20:39     ` Cyrill Gorcunov via Tarantool-patches [this message]
2022-01-12 14:01       ` Serge Petrenko via Tarantool-patches
2022-01-12 21:30         ` Vladislav Shpilevoy via Tarantool-patches
2022-01-13 10:13           ` Serge Petrenko via Tarantool-patches
2022-01-13 23:32             ` Vladislav Shpilevoy via Tarantool-patches
2022-01-14 10:20               ` Serge Petrenko via Tarantool-patches
2022-01-14 10:33                 ` Cyrill Gorcunov via Tarantool-patches
2021-12-30 20:23 ` [Tarantool-patches] [PATCH v27 3/3] test: add gh-6036-qsync-order test Cyrill Gorcunov via Tarantool-patches
2022-01-10 14:29   ` Serge Petrenko via Tarantool-patches
2022-01-11 20:41     ` Cyrill Gorcunov 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=Yd3rDf460NT+KbvJ@grain \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=gorcunov@gmail.com \
    --cc=sergepetrenko@tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v27 2/3] qsync: order access to the limbo terms' \
    /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