From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Vladimir Davydov Subject: [PATCH 2/5] memtx: don't call begin_buid and end_build for new pk after recovery Date: Tue, 3 Apr 2018 20:37:40 +0300 Message-Id: <1298fbd1d051b9d36e55e641f2b9786f1f7dcf81.1522775293.git.vdavydov.dev@gmail.com> In-Reply-To: References: In-Reply-To: References: To: kostja@tarantool.org Cc: tarantool-patches@freelists.org List-ID: Basically, index_begin_build() followed by index_end_build() is a no-op. There's absolutely no point in calling it for primary indexes after initial recovery has completed. --- src/box/memtx_space.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/src/box/memtx_space.c b/src/box/memtx_space.c index e0fa3e2c..ec6f6db6 100644 --- a/src/box/memtx_space.c +++ b/src/box/memtx_space.c @@ -680,12 +680,12 @@ memtx_space_create_index(struct space *space, struct index_def *index_def) * then the primary key is not built, otherwise it's created * right away. */ -static void -memtx_space_do_add_primary_key(struct space *space, - enum memtx_recovery_state state) +static int +memtx_space_add_primary_key(struct space *space) { struct memtx_space *memtx_space = (struct memtx_space *)space; - switch (state) { + struct memtx_engine *memtx = (struct memtx_engine *)space->engine; + switch (memtx->state) { case MEMTX_INITIALIZED: panic("can't create a new space before snapshot recovery"); break; @@ -694,23 +694,12 @@ memtx_space_do_add_primary_key(struct space *space, memtx_space->replace = memtx_space_replace_build_next; break; case MEMTX_FINAL_RECOVERY: - index_begin_build(space->index[0]); - index_end_build(space->index[0]); memtx_space->replace = memtx_space_replace_primary_key; break; case MEMTX_OK: - index_begin_build(space->index[0]); - index_end_build(space->index[0]); memtx_space->replace = memtx_space_replace_all_keys; break; } -} - -static int -memtx_space_add_primary_key(struct space *space) -{ - struct memtx_engine *memtx = (struct memtx_engine *)space->engine; - memtx_space_do_add_primary_key(space, memtx->state); return 0; } @@ -752,7 +741,8 @@ memtx_space_drop_primary_key(struct space *space) static void memtx_init_system_space(struct space *space) { - memtx_space_do_add_primary_key(space, MEMTX_OK); + struct memtx_space *memtx_space = (struct memtx_space *)space; + memtx_space->replace = memtx_space_replace_all_keys; } static int -- 2.11.0