From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> To: tarantool-patches@freelists.org Cc: vdavydov.dev@gmail.com Subject: [PATCH 8/8] box: introduce promotion GC Date: Wed, 8 Aug 2018 01:03:51 +0300 [thread overview] Message-ID: <d5896ad5224b43853c4dd04487ef89c90e2fa45b.1533679264.git.v.shpilevoy@tarantool.org> (raw) In-Reply-To: <cover.1533679264.git.v.shpilevoy@tarantool.org> In-Reply-To: <cover.1533679264.git.v.shpilevoy@tarantool.org> In the previous commit a promotion protocol was introduced. Each promotion round produces messages stored in the _promotion space. After a number of promotions the space can become too big. But it is not necessary to store those promotion rounds after which another successfull promotion was executed. This patch introduces garbage collecting, so after each successfull promotion old rounds are purged. Follow up #3055 --- src/box/promote.c | 15 +++++++++++++-- test/promote/basic.result | 23 +++++++++++++++++++++++ test/promote/basic.test.lua | 11 +++++++++++ 3 files changed, 47 insertions(+), 2 deletions(-) diff --git a/src/box/promote.c b/src/box/promote.c index dcc39b5bd..eab348f70 100644 --- a/src/box/promote.c +++ b/src/box/promote.c @@ -695,7 +695,7 @@ rollback: } int -box_ctl_promote_reset(void) +promote_reset_until(uint32_t until) { uint32_t id, next_id = 0; struct index *pk = space_index(space_by_id(BOX_PROMOTION_ID), 0); @@ -703,7 +703,15 @@ box_ctl_promote_reset(void) id = next_id; if (promote_clean_round(id, &next_id, pk) != 0) return -1; - } while (id != next_id); + } while (id != next_id && next_id < until); + return 0; +} + +int +box_ctl_promote_reset(void) +{ + if (promote_reset_until(UINT32_MAX) != 0) + return -1; promote_state.phase = PROMOTE_PHASE_NON_ACTIVE; promote_state.is_role_committed = false; return 0; @@ -739,6 +747,9 @@ stop: say_info("promotion timer is stopped"); assert(fiber() == promote_state.timer); promote_state.timer = NULL; + if (promote_state.role == PROMOTE_ROLE_INITIATOR && + promote_state.phase == PROMOTE_PHASE_SUCCESS) + promote_reset_until(promote_state.round_id); return 0; } diff --git a/test/promote/basic.result b/test/promote/basic.result index f70659963..47c92e257 100644 --- a/test/promote/basic.result +++ b/test/promote/basic.result @@ -464,6 +464,29 @@ promotion_history() --- - [] ... +-- +-- Test promotion GC. +-- +_ = test_run:switch('box2') +--- +... +box.ctl.promote() +--- +- true +... +_ = test_run:switch('box1') +--- +... +box.ctl.promote() +--- +- true +... +-- Each successfull round for 4 instance cluster produces 9 +-- records. +#promotion_history() < 10 +--- +- true +... _ = test_run:switch('default') --- ... diff --git a/test/promote/basic.test.lua b/test/promote/basic.test.lua index 4138745b5..835208f06 100644 --- a/test/promote/basic.test.lua +++ b/test/promote/basic.test.lua @@ -156,5 +156,16 @@ promote_info() box.ctl.promote_reset() promotion_history() +-- +-- Test promotion GC. +-- +_ = test_run:switch('box2') +box.ctl.promote() +_ = test_run:switch('box1') +box.ctl.promote() +-- Each successfull round for 4 instance cluster produces 9 +-- records. +#promotion_history() < 10 + _ = test_run:switch('default') test_run:drop_cluster(CLUSTER) -- 2.15.2 (Apple Git-101.1)
prev parent reply other threads:[~2018-08-07 22:03 UTC|newest] Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-08-07 22:03 [PATCH 0/8] box.ctl.promote Vladislav Shpilevoy 2018-08-07 22:03 ` [PATCH 1/8] rfc: describe box.ctl.promote protocol Vladislav Shpilevoy 2018-08-07 22:03 ` [PATCH 2/8] box: rename process_rw to process_dml Vladislav Shpilevoy 2018-08-13 8:20 ` Vladimir Davydov 2018-08-07 22:03 ` [PATCH 3/8] Add 'exact_field_count' parameter to options decoder Vladislav Shpilevoy 2018-08-13 8:30 ` Vladimir Davydov 2018-08-07 22:03 ` [PATCH 4/8] box: remove orphan check from box_is_ro() Vladislav Shpilevoy 2018-08-13 8:34 ` Vladimir Davydov 2018-08-07 22:03 ` [PATCH 5/8] Fix gcov on Mac Vladislav Shpilevoy 2018-08-07 22:03 ` [PATCH 6/8] box: introduce _promotion space Vladislav Shpilevoy 2018-08-07 22:03 ` [PATCH 7/8] box: introduce box.ctl.promote Vladislav Shpilevoy 2018-08-13 8:58 ` Vladimir Davydov 2018-08-07 22:03 ` Vladislav Shpilevoy [this message]
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=d5896ad5224b43853c4dd04487ef89c90e2fa45b.1533679264.git.v.shpilevoy@tarantool.org \ --to=v.shpilevoy@tarantool.org \ --cc=tarantool-patches@freelists.org \ --cc=vdavydov.dev@gmail.com \ --subject='Re: [PATCH 8/8] box: introduce promotion GC' \ /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