[tarantool-patches] Re: [PATCH] recovery: build secondary index in hot standby mode

Georgy Kirichenko georgy at tarantool.org
Mon Sep 30 11:42:01 MSK 2019


On Monday, September 16, 2019 10:33:36 PM MSK Ilya Kosarev wrote:
Hi! Thanks for the patch.

Please, consider to take the xdir_collect_inprogress invocation under gc 
responsibility. LGTM except that.


> End recovery (which means building secondary indexes) just after
> last known log file was read. This allows fast switch to hot standby
> instance without any delay for secondary index to be built.
> 
> Closes #4135
> ---
> Branch:
> https://github.com/tarantool/tarantool/tree/i.kosarev/gh-4135-secondary-ind
> ex-for-hot-standby Issue: https://github.com/tarantool/tarantool/issues/4135
> 
>  src/box/box.cc                        |  3 ++-
>  src/box/memtx_engine.c                |  1 -
>  test/replication/hot_standby.result   | 16 ++++++++++++++++
>  test/replication/hot_standby.test.lua |  2 ++
>  4 files changed, 20 insertions(+), 2 deletions(-)
> 
> diff --git a/src/box/box.cc b/src/box/box.cc
> index 40920e649..060f8d2fe 100644
> --- a/src/box/box.cc
> +++ b/src/box/box.cc
> @@ -1968,6 +1968,7 @@ local_recovery(const struct tt_uuid *instance_uuid,
> 
>  	engine_begin_final_recovery_xc();
>  	recover_remaining_wals(recovery, &wal_stream.base, NULL, false);
> +	engine_end_recovery_xc();
>  	/*
>  	 * Leave hot standby mode, if any, only after
>  	 * acquiring the lock.
> @@ -2005,7 +2006,7 @@ local_recovery(const struct tt_uuid *instance_uuid,
>  	if (wal_enable() != 0)
>  		diag_raise();
> 
> -	engine_end_recovery_xc();
> +	xdir_collect_inprogress(&memtx->snap_dir);
> 
>  	/* Check replica set UUID. */
>  	if (!tt_uuid_is_nil(replicaset_uuid) &&
> diff --git a/src/box/memtx_engine.c b/src/box/memtx_engine.c
> index eb11346c1..8bdf7f068 100644
> --- a/src/box/memtx_engine.c
> +++ b/src/box/memtx_engine.c
> @@ -315,7 +315,6 @@ memtx_engine_end_recovery(struct engine *engine)
>  		if (space_foreach(memtx_build_secondary_keys, memtx) != 
0)
>  			return -1;
>  	}
> -	xdir_collect_inprogress(&memtx->snap_dir);
>  	return 0;
>  }
> 
> diff --git a/test/replication/hot_standby.result
> b/test/replication/hot_standby.result index b140887df..5dc12a462 100644
> --- a/test/replication/hot_standby.result
> +++ b/test/replication/hot_standby.result
> @@ -130,6 +130,9 @@ space = box.schema.space.create('tweedledum', {engine =
> engine}) index = space:create_index('primary', {type = 'tree'})
>  ---
>  ...
> +index = space:create_index('secondary', {type = 'tree'})
> +---
> +...
>  -- set begin lsn on master, replica and hot_standby.
>  test_run:cmd("set variable replica_port to 'replica.listen'")
>  ---
> @@ -203,6 +206,19 @@ test_run:cmd("switch hot_standby")
>  _wait_lsn(10)
>  ---
>  ...
> +box.space.tweedledum.index[1]:select()
> +---
> +- - [1, 'the tuple 1']
> +  - [2, 'the tuple 2']
> +  - [3, 'the tuple 3']
> +  - [4, 'the tuple 4']
> +  - [5, 'the tuple 5']
> +  - [6, 'the tuple 6']
> +  - [7, 'the tuple 7']
> +  - [8, 'the tuple 8']
> +  - [9, 'the tuple 9']
> +  - [10, 'the tuple 10']
> +...
>  test_run:cmd("switch replica")
>  ---
>  - true
> diff --git a/test/replication/hot_standby.test.lua
> b/test/replication/hot_standby.test.lua index f43982f15..73a5329a7 100644
> --- a/test/replication/hot_standby.test.lua
> +++ b/test/replication/hot_standby.test.lua
> @@ -71,6 +71,7 @@ box.info.status
> 
>  space = box.schema.space.create('tweedledum', {engine = engine})
>  index = space:create_index('primary', {type = 'tree'})
> +index = space:create_index('secondary', {type = 'tree'})
> 
>  -- set begin lsn on master, replica and hot_standby.
>  test_run:cmd("set variable replica_port to 'replica.listen'")
> @@ -92,6 +93,7 @@ _select(1, 10)
>  -- Check box.info.vclock is updated during hot standby.
>  test_run:cmd("switch hot_standby")
>  _wait_lsn(10)
> +box.space.tweedledum.index[1]:select()
> 
>  test_run:cmd("switch replica")
>  _wait_lsn(10)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: This is a digitally signed message part.
URL: <https://lists.tarantool.org/pipermail/tarantool-patches/attachments/20190930/4713f928/attachment.sig>


More information about the Tarantool-patches mailing list