Tarantool development patches archive
 help / color / mirror / Atom feed
From: Cyrill Gorcunov via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
Cc: tml <tarantool-patches@dev.tarantool.org>
Subject: Re: [Tarantool-patches] [PATCH v10 2/4] limbo: order access to the limbo terms
Date: Fri, 6 Aug 2021 18:20:10 +0300	[thread overview]
Message-ID: <YQ1TKp9vOdVyb9K3@grain> (raw)
In-Reply-To: <f485bfc5-d2ed-384d-63ea-1ff6a21c0e1c@tarantool.org>

On Fri, Aug 06, 2021 at 01:29:57AM +0200, Vladislav Shpilevoy wrote:
> >  apply_synchro_row(uint32_t replica_id, struct xrow_header *row)
> >  {
> >  	assert(iproto_type_is_synchro_request(row->type));
> > +	int rc = 0;
> >  
> >  	struct synchro_request req;
> >  	if (xrow_decode_synchro(row, &req) != 0)
> >  		goto err;
> >  
> > +	txn_limbo_term_lock(&txn_limbo);
> 
> Maybe you should hide the lock from the API. Instead, do similar to
> what transactions do:
> 
> 	int txn_limbo_process_begin(limbo *);
> 	void txn_limbo_process_commit(limbo *, request *);
> 	void txn_limbo_process_rollback(limbo *);
> 
> begin would take the lock, commit would do the request and
> unlock, rollback would only unlock. Commit and rollback you
> call from apply_synchro_row_cb depend in on the WAL write
> result.
> 
> Then the locks would disappear from the API, right?

Unfortunatelly locking is needed not only for processing but
for reading terms as well. We have a few helpers more which
are waiting the other fibers to complete before reading terms.

applier_apply_tx
  applier_synchro_filter_tx
    txn_limbo_is_replica_outdated
      txn_limbo_term_lock
        txn_limbo_replica_term_locked
      txn_limbo_term_unlock

And a number of calls for txn_limbo_replica_term which reads
term in a locked way because we need to eliminate potential
race here and fetch only last written data.

So no, locking won't disappear. Another option may be to
introduce preemption disabling (just like kernel does for
tasks which should not be rescheduled on a core while
they are wating for some action to complete). Then our
write for synchro packets would look like

	preempt_disable();
	rc = journal_write();
	preempt_enable();

which would guarantee us that while we're waiting the journal
to finish its write no other fibers from the cord will be
executed and we gotta be woken up once write is complete.

This way I think we will be allowed to drop locking at all
because main problem is exactly because of other fibers get
running while we're writing synchro data.

> In the next patch you would make txn_limbo_process_begin()
> also take the request to validate it. Then the 'filtering'
> would become internal to the limbo.
> 
> >  	struct replica_cb_data rcb_data;
> >  	struct synchro_entry entry;

	Cyrill

  reply	other threads:[~2021-08-06 15:20 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-04 19:07 [Tarantool-patches] [PATCH v10 0/4] limbo: implement packets filtering Cyrill Gorcunov via Tarantool-patches
2021-08-04 19:07 ` [Tarantool-patches] [PATCH v10 1/4] latch: add latch_is_locked helper Cyrill Gorcunov via Tarantool-patches
2021-08-04 19:07 ` [Tarantool-patches] [PATCH v10 2/4] limbo: order access to the limbo terms Cyrill Gorcunov via Tarantool-patches
2021-08-05 23:29   ` Vladislav Shpilevoy via Tarantool-patches
2021-08-06 15:20     ` Cyrill Gorcunov via Tarantool-patches [this message]
2021-08-08 14:34       ` Vladislav Shpilevoy via Tarantool-patches
2021-08-09 16:24         ` Cyrill Gorcunov via Tarantool-patches
2021-08-10 12:27           ` Vladislav Shpilevoy via Tarantool-patches
2021-08-10 12:57             ` Cyrill Gorcunov via Tarantool-patches
2021-08-23 11:32     ` Serge Petrenko via Tarantool-patches
2021-08-23 11:41       ` Cyrill Gorcunov via Tarantool-patches
2021-09-01 16:04         ` Cyrill Gorcunov via Tarantool-patches
2021-08-04 19:07 ` [Tarantool-patches] [PATCH v10 3/4] limbo: filter incoming synchro requests Cyrill Gorcunov via Tarantool-patches
2021-08-05 23:33   ` Vladislav Shpilevoy via Tarantool-patches
2021-08-06 19:01     ` Cyrill Gorcunov via Tarantool-patches
2021-08-08 11:43       ` Vladislav Shpilevoy via Tarantool-patches
2021-08-08 22:35         ` Cyrill Gorcunov via Tarantool-patches
2021-08-10 12:31           ` Vladislav Shpilevoy via Tarantool-patches
2021-08-10 14:36             ` Cyrill Gorcunov via Tarantool-patches
2021-08-12 16:59               ` Vladislav Shpilevoy via Tarantool-patches
2021-08-04 19:07 ` [Tarantool-patches] [PATCH v10 4/4] test: add replication/gh-6036-rollback-confirm Cyrill Gorcunov via Tarantool-patches
2021-08-05  9:38 ` [Tarantool-patches] [PATCH v10 0/4] limbo: implement packets filtering Cyrill Gorcunov via Tarantool-patches
2021-08-05 23:29 ` Vladislav Shpilevoy via Tarantool-patches
2021-08-08 22:03   ` 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=YQ1TKp9vOdVyb9K3@grain \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=gorcunov@gmail.com \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v10 2/4] limbo: 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