[Tarantool-patches] [PATCH 6/7] box: introduce `box.ctl.demote`

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Sat Jun 19 01:52:59 MSK 2021


Thanks for the patch!

See 3 comments below.

>     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

>     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.

> @@ -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.



More information about the Tarantool-patches mailing list