Tarantool development patches archive
 help / color / mirror / Atom feed
From: Serge Petrenko via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>, gorcunov@gmail.com
Cc: tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH 6/7] box: introduce `box.ctl.demote`
Date: Mon, 21 Jun 2021 17:56:09 +0300
Message-ID: <fa267cfe-e4e9-ffb3-c7be-95cd3e47371f@tarantool.org> (raw)
In-Reply-To: <d5162eb0-0b24-0ed7-4bb1-cdca92323cb9@tarantool.org>



19.06.2021 01:52, Vladislav Shpilevoy пишет:
> Thanks for the patch!
>
> See 3 comments below.

Thanks for the review!

>>      box: introduce `box.ctl.demote`
>>      
>>      Introduce a new journal entry, DEMOTE. The entry has the same meaning as
>>      PROMOTE, with the only difference that it clears limbo ownership instead
>>      of transferring it to the issuer.
>>      
>>      Introduce `box.ctl.demote`, which works exactly like `box.ctl.promote`,
>>      but results in writing DEMOTE instead of PROMOTE.
>>      
>>      A new request was necessary instead of simply writing PROMOTE(origin_id
>>      = 0), because origin_id is deduced from row.replica_id, which cannot be
>>      0 for replicated rows (it's always equal to instance_id of the row
>>      originator).
>>      
>>      Closes #6034
>>      
>>      @TarantoolBod document
> 1. TarantoolBod -> TarantoolBot

Fixed.

>
>>      Title: box.ctl.demote
>>      
>>      `box.ctl.demote()` is a new function, which works exactly like
>>      `box.ctl.promote()`, with one exception that it results in the instance
>>      writing DEMOTE request to WAL instead of a PROMOTE request.
>>      
>>      A DEMOTE request (DEMOTE = 32) copies PROMOTE behaviour (it clears the
>>      limbo as well), but clears limbo ownership instead of assigning it to a
>>      new instance.
>>
>> diff --git a/src/box/box.cc b/src/box/box.cc
>> index 53a8f80e5..f2bde910c 100644
>> --- a/src/box/box.cc
>> +++ b/src/box/box.cc
>> @@ -1527,8 +1527,8 @@ box_wait_quorum(uint32_t lead_id, int64_t target_lsn, int quorum,
>>   	return 0;
>>   }
>>   
>> -int
>> -box_promote(void)
>> +static int
>> +box_clear_synchro_queue(bool demote)
>>   {
>>   	/* A guard to block multiple simultaneous function invocations. */
>>   	static bool in_promote = false;
> 2. A few lines below there is an error message about simultaneous invocations.
> It still talks only about promote(), but I think it should mention demote() too.

Sure, fixed. Please find the diff below.

>
>> @@ -1691,10 +1691,16 @@ promote:
> 3. That looks strange.
>
> tarantool> box.cfg{election_mode = 'candidate'}
>
> tarantool> box.info.election
> ---
> - state: leader
>    vote: 1
>    leader: 1
>    term: 2
> ...
>
> tarantool> box.ctl.demote()
> ---
> ...
>
> tarantool> box.info.election
> ---
> - state: leader
>    vote: 1
>    leader: 1
>    term: 2
> ...
>
> So demote() didn't demote the leader nor raised an error. I
> would rather expect from demote() that it can be called only
> on the leader, and always makes it a follower. Even if the
> node is mode='candidate' and would elect itself again, still
> I would think it should step down in the current term.
>

Ok, I see.

Maybe rename `box.ctl.demote()` to something else?
The notorious `clear_synchro_queue`, for example.
This way the user won't expect the function to demote a leader.

I intended the function to be used as PROMOTE for replica id 0,
i.e. someone has to become the leader before writing PROMOTE/DEMOTE.

This means both functions result in electing a leader. But for a different
purpose: either to pin the limbo to it, or free the limbo from any other 
owner.

=================================================

diff --git a/src/box/box.cc b/src/box/box.cc
index f2bde910c..44ee327e9 100644
--- a/src/box/box.cc
+++ b/src/box/box.cc
@@ -1533,7 +1533,8 @@ box_clear_synchro_queue(bool demote)
         /* A guard to block multiple simultaneous function invocations. */
         static bool in_promote = false;
         if (in_promote) {
-               diag_set(ClientError, ER_UNSUPPORTED, "box.ctl.promote",
+               diag_set(ClientError, ER_UNSUPPORTED,
+                        demote ? "box.ctl.demote" : "box.ctl.promote",
                          "simultaneous invocations");
                 return -1;
         }


=================================================

-- 
Serge Petrenko


  reply	other threads:[~2021-06-21 14:56 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-10 13:32 [Tarantool-patches] [PATCH 0/7] forbid implicit limbo ownership transition Serge Petrenko via Tarantool-patches
2021-06-10 13:32 ` [Tarantool-patches] [PATCH 1/7] replication: always send raft state to subscribers Serge Petrenko via Tarantool-patches
2021-06-10 16:47   ` Cyrill Gorcunov via Tarantool-patches
2021-06-11  8:43     ` Serge Petrenko via Tarantool-patches
2021-06-11  8:44       ` Cyrill Gorcunov via Tarantool-patches
2021-06-15 20:53   ` Vladislav Shpilevoy via Tarantool-patches
2021-06-17 21:00     ` Serge Petrenko via Tarantool-patches
2021-06-10 13:32 ` [Tarantool-patches] [PATCH 2/7] replication: forbid implicit limbo owner transition Serge Petrenko via Tarantool-patches
2021-06-15 20:55   ` Vladislav Shpilevoy via Tarantool-patches
2021-06-17 21:00     ` Serge Petrenko via Tarantool-patches
2021-06-18 22:49   ` Vladislav Shpilevoy via Tarantool-patches
2021-06-21 10:13     ` Serge Petrenko via Tarantool-patches
2021-06-10 13:32 ` [Tarantool-patches] [PATCH 3/7] txn_limbo: fix promote term filtering Serge Petrenko via Tarantool-patches
2021-06-15 20:57   ` Vladislav Shpilevoy via Tarantool-patches
2021-06-17 21:00     ` Serge Petrenko via Tarantool-patches
2021-06-18 22:49       ` Vladislav Shpilevoy via Tarantool-patches
2021-06-21  8:55         ` Serge Petrenko via Tarantool-patches
2021-06-10 13:32 ` [Tarantool-patches] [PATCH 4/7] txn_limbo: persist the latest effective promote in snapshot Serge Petrenko via Tarantool-patches
2021-06-15 20:59   ` Vladislav Shpilevoy via Tarantool-patches
2021-06-17 21:00     ` Serge Petrenko via Tarantool-patches
2021-06-10 13:32 ` [Tarantool-patches] [PATCH 5/7] replication: send latest effective promote in initial join Serge Petrenko via Tarantool-patches
2021-06-15 21:00   ` Vladislav Shpilevoy via Tarantool-patches
2021-06-17 21:00     ` Serge Petrenko via Tarantool-patches
2021-06-18 22:52       ` Vladislav Shpilevoy via Tarantool-patches
2021-06-21 10:12         ` Serge Petrenko via Tarantool-patches
2021-06-10 13:32 ` [Tarantool-patches] [PATCH 6/7] box: introduce `box.ctl.demote` Serge Petrenko via Tarantool-patches
2021-06-18 22:52   ` Vladislav Shpilevoy via Tarantool-patches
2021-06-21 14:56     ` Serge Petrenko via Tarantool-patches [this message]
2021-06-10 13:32 ` [Tarantool-patches] [PATCH 7/7] box: make promote/demote always bump the term Serge Petrenko via Tarantool-patches
2021-06-15 21:00   ` Vladislav Shpilevoy via Tarantool-patches
2021-06-17 21:00     ` Serge Petrenko via Tarantool-patches
2021-06-18 22:53   ` Vladislav Shpilevoy via Tarantool-patches
2021-06-21 15:02     ` Serge Petrenko via Tarantool-patches
2021-06-15 20:53 ` [Tarantool-patches] [PATCH 0/7] forbid implicit limbo ownership transition Vladislav Shpilevoy 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=fa267cfe-e4e9-ffb3-c7be-95cd3e47371f@tarantool.org \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=gorcunov@gmail.com \
    --cc=sergepetrenko@tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    /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

Tarantool development patches archive

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://lists.tarantool.org/tarantool-patches/0 tarantool-patches/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 tarantool-patches tarantool-patches/ https://lists.tarantool.org/tarantool-patches \
		tarantool-patches@dev.tarantool.org.
	public-inbox-index tarantool-patches

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git