From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: tarantool-patches@dev.tarantool.org, olegrok@tarantool.org
Subject: [Tarantool-patches] [PATCH vshard 4/7] test: clear route map, respecting statistics
Date: Fri, 1 May 2020 02:16:31 +0200 [thread overview]
Message-ID: <d099adade84511ce90fdffe3ec3d0f2e2499db2d.1588292014.git.v.shpilevoy@tarantool.org> (raw)
In-Reply-To: <cover.1588292014.git.v.shpilevoy@tarantool.org>
Router's test sometimes need to wipe the route map. Simple reset
it to {} may produce unexpected results, because route map is not
just a table. It is also statistics in replicaset objects.
Inconsistent statistics may lead to failing tests in surprising
places. That becomes even more true with forthcoming patches,
which rework the statistics a little bit so it actually affects
something inside the router.
Part of #210
---
test/router/router.result | 12 ++++--------
test/router/router.test.lua | 10 ++++------
vshard/router/init.lua | 9 +++++++++
3 files changed, 17 insertions(+), 14 deletions(-)
diff --git a/test/router/router.result b/test/router/router.result
index 267a3e9..df7be4a 100644
--- a/test/router/router.result
+++ b/test/router/router.result
@@ -175,7 +175,7 @@ vshard.router.bootstrap()
--
-- gh-108: negative bucket count on discovery.
--
-vshard.router.static.route_map = {}
+vshard.router.static:_route_map_clear()
---
...
rets = {}
@@ -985,10 +985,8 @@ _ = test_run:cmd("setopt delimiter ';'")
---
...
for i = 1, 100 do
- local rs = vshard.router.static.route_map[i]
- assert(rs)
- rs.bucket_count = rs.bucket_count - 1
- vshard.router.static.route_map[i] = nil
+ assert(vshard.router.static.route_map[i])
+ vshard.router.static:_bucket_reset(i)
end;
---
...
@@ -1243,9 +1241,7 @@ end;
vshard.router.cfg(cfg);
---
...
-vshard.router.static.route_map = {};
----
-...
+vshard.router.static:_route_map_clear()
vshard.router.internal.errinj.ERRINJ_LONG_DISCOVERY = false;
---
...
diff --git a/test/router/router.test.lua b/test/router/router.test.lua
index c36026d..97dce49 100644
--- a/test/router/router.test.lua
+++ b/test/router/router.test.lua
@@ -73,7 +73,7 @@ vshard.router.bootstrap()
--
-- gh-108: negative bucket count on discovery.
--
-vshard.router.static.route_map = {}
+vshard.router.static:_route_map_clear()
rets = {}
function do_echo() table.insert(rets, vshard.router.callro(1, 'echo', {1})) end
f1 = fiber.create(do_echo) f2 = fiber.create(do_echo)
@@ -331,10 +331,8 @@ _ = test_run:switch('router_1')
--
_ = test_run:cmd("setopt delimiter ';'")
for i = 1, 100 do
- local rs = vshard.router.static.route_map[i]
- assert(rs)
- rs.bucket_count = rs.bucket_count - 1
- vshard.router.static.route_map[i] = nil
+ assert(vshard.router.static.route_map[i])
+ vshard.router.static:_bucket_reset(i)
end;
_ = test_run:cmd("setopt delimiter ''");
calculate_known_buckets()
@@ -453,7 +451,7 @@ while vshard.router.internal.errinj.ERRINJ_LONG_DISCOVERY ~= 'waiting' do
fiber.sleep(0.02)
end;
vshard.router.cfg(cfg);
-vshard.router.static.route_map = {};
+vshard.router.static:_route_map_clear()
vshard.router.internal.errinj.ERRINJ_LONG_DISCOVERY = false;
-- Do discovery iteration. Upload buckets from the
-- first replicaset.
diff --git a/vshard/router/init.lua b/vshard/router/init.lua
index ebd8356..43b2ef7 100644
--- a/vshard/router/init.lua
+++ b/vshard/router/init.lua
@@ -112,6 +112,13 @@ local function bucket_reset(router, bucket_id)
router.route_map[bucket_id] = nil
end
+local function route_map_clear(router)
+ router.route_map = {}
+ for _, rs in pairs(router.replicasets) do
+ rs.bucket_count = 0
+ end
+end
+
--
-- Increase/decrease number of routers which require to collect
-- a lua garbage and change state of the `lua_gc` fiber.
@@ -1173,6 +1180,8 @@ local router_mt = {
bucket_discovery = bucket_discovery;
discovery_wakeup = discovery_wakeup;
discovery_set = discovery_set,
+ _route_map_clear = route_map_clear,
+ _bucket_reset = bucket_reset,
}
}
--
2.21.1 (Apple Git-122.3)
next prev parent reply other threads:[~2020-05-01 0:16 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-01 0:16 [Tarantool-patches] [PATCH vshard 0/7] Router extended discovery Vladislav Shpilevoy
2020-05-01 0:16 ` [Tarantool-patches] [PATCH vshard 1/7] test: print errors in a portable way Vladislav Shpilevoy
2020-05-01 16:58 ` Oleg Babin
2020-05-02 20:08 ` Vladislav Shpilevoy
2020-05-04 14:26 ` Oleg Babin
2020-05-01 0:16 ` [Tarantool-patches] [PATCH vshard 2/7] router: introduce discovery_mode Vladislav Shpilevoy
2020-05-01 16:59 ` Oleg Babin
2020-05-01 0:16 ` [Tarantool-patches] [PATCH vshard 3/7] test: disable router discovery for some tests Vladislav Shpilevoy
2020-05-01 17:00 ` Oleg Babin
2020-05-02 20:09 ` Vladislav Shpilevoy
2020-05-04 14:26 ` Oleg Babin
2020-05-01 0:16 ` Vladislav Shpilevoy [this message]
2020-05-01 17:00 ` [Tarantool-patches] [PATCH vshard 4/7] test: clear route map, respecting statistics Oleg Babin
2020-05-01 0:16 ` [Tarantool-patches] [PATCH vshard 5/7] router: keep known bucket count stat up to date Vladislav Shpilevoy
2020-05-01 17:01 ` Oleg Babin
2020-05-01 0:16 ` [Tarantool-patches] [PATCH vshard 6/7] router: make discovery smoother in a big cluster Vladislav Shpilevoy
2020-05-01 17:01 ` Oleg Babin
2020-05-02 20:12 ` Vladislav Shpilevoy
2020-05-04 14:26 ` Oleg Babin
2020-05-04 21:09 ` Vladislav Shpilevoy
2020-05-06 8:27 ` Oleg Babin
2020-05-07 22:45 ` Konstantin Osipov
2020-05-08 19:56 ` Vladislav Shpilevoy
2020-05-09 7:37 ` Konstantin Osipov
2020-05-01 0:16 ` [Tarantool-patches] [PATCH vshard 7/7] router: introduce discovery mode 'once' Vladislav Shpilevoy
2020-05-01 17:02 ` Oleg Babin
2020-05-02 20:12 ` Vladislav Shpilevoy
2020-05-04 14:27 ` Oleg Babin
2020-05-06 20:54 ` [Tarantool-patches] [PATCH vshard 0/7] Router extended discovery Vladislav Shpilevoy
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=d099adade84511ce90fdffe3ec3d0f2e2499db2d.1588292014.git.v.shpilevoy@tarantool.org \
--to=v.shpilevoy@tarantool.org \
--cc=olegrok@tarantool.org \
--cc=tarantool-patches@dev.tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH vshard 4/7] test: clear route map, respecting statistics' \
/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