Skip to content

Commit

Permalink
storage: return to fullmesh topology
Browse files Browse the repository at this point in the history
Fullmesh was disabled by #66 because of its too raw
implementation in Tarantool. Now it is ripe enough to be
granted a second chance.

Fullmesh provides a benefit of a constant complete sync. If a
tuple is written on a master right before its demotion, a new
master still will receive the tuple from the old one.

Closes #83
  • Loading branch information
Gerold103 committed Aug 22, 2018
1 parent 630e607 commit 5292cfe
Show file tree
Hide file tree
Showing 9 changed files with 158 additions and 11 deletions.
4 changes: 2 additions & 2 deletions test/misc/check_uuid_on_connect.result
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@ test_run:cmd('create server bad_uuid_2_a_repaired with script="misc/bad_uuid_2_a
---
- true
...
test_run:cmd('start server bad_uuid_2_a_repaired')
test_run:cmd('start server bad_uuid_2_a_repaired with wait_load=False, wait=False')
---
- true
...
test_run:cmd('create server bad_uuid_2_b with script="misc/bad_uuid_2_b.lua", wait=False, wait_load=False')
---
- true
...
test_run:cmd('start server bad_uuid_2_b')
test_run:cmd('start server bad_uuid_2_b with wait_load=False, wait=False')
---
- true
...
Expand Down
4 changes: 2 additions & 2 deletions test/misc/check_uuid_on_connect.test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ test_run:cmd("switch default")
test_run:drop_cluster(REPLICASET_2)
REPLICASET_2 = { 'bad_uuid_2_a_repaired', 'bad_uuid_2_b' }
test_run:cmd('create server bad_uuid_2_a_repaired with script="misc/bad_uuid_2_a_repaired.lua", wait=False, wait_load=False')
test_run:cmd('start server bad_uuid_2_a_repaired')
test_run:cmd('start server bad_uuid_2_a_repaired with wait_load=False, wait=False')
test_run:cmd('create server bad_uuid_2_b with script="misc/bad_uuid_2_b.lua", wait=False, wait_load=False')
test_run:cmd('start server bad_uuid_2_b')
test_run:cmd('start server bad_uuid_2_b with wait_load=False, wait=False')
util.wait_master(test_run, REPLICASET_2, 'bad_uuid_2_a_repaired')

test_run:switch('bad_uuid_1_a')
Expand Down
99 changes: 99 additions & 0 deletions test/misc/fullmesh.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
test_run = require('test_run').new()
---
...
REPLICASET_1 = { 'storage_1_a', 'storage_1_b' }
---
...
REPLICASET_2 = { 'storage_2_a', 'storage_2_b' }
---
...
test_run:create_cluster(REPLICASET_1, 'misc')
---
...
test_run:create_cluster(REPLICASET_2, 'misc')
---
...
util = require('util')
---
...
test_run:wait_fullmesh(REPLICASET_1)
---
...
test_run:wait_fullmesh(REPLICASET_2)
---
...
util.map_evals(test_run, {REPLICASET_1, REPLICASET_2}, 'bootstrap_storage(\'memtx\')')
---
...
--
-- gh-83: use fullmesh topology in vshard. Scenario of the test:
-- start writing a tuple on a master. Then switch master. After
-- switch the tuple still should be sent from the slave to a new
-- master.
--
_ = test_run:switch('storage_1_a')
---
...
-- Block new requests sending.
box.error.injection.set("ERRINJ_WAL_DELAY", true)
---
- ok
...
f = fiber.create(function() box.space.test:replace{1, 1} end)
---
...
box.space.test:select{}
---
- - [1, 1]
...
cfg.sharding[util.replicasets[1]].replicas[util.name_to_uuid.storage_1_b].master = true
---
...
cfg.sharding[util.replicasets[1]].replicas[util.name_to_uuid.storage_1_a].master = false
---
...
vshard.storage.cfg(cfg, util.name_to_uuid.storage_1_a)
---
...
_ = test_run:switch('storage_1_b')
---
...
cfg.sharding[util.replicasets[1]].replicas[util.name_to_uuid.storage_1_b].master = true
---
...
cfg.sharding[util.replicasets[1]].replicas[util.name_to_uuid.storage_1_a].master = false
---
...
vshard.storage.cfg(cfg, util.name_to_uuid.storage_1_b)
---
...
box.space.test:select{}
---
- []
...
_ = test_run:switch('storage_1_a')
---
...
box.error.injection.set("ERRINJ_WAL_DELAY", false)
---
- ok
...
_ = test_run:switch('storage_1_b')
---
...
while box.space.test:count() == 0 do fiber.sleep(0.1) end
---
...
box.space.test:select{}
---
- - [1, 1]
...
_ = test_run:cmd("switch default")
---
...
test_run:drop_cluster(REPLICASET_2)
---
...
test_run:drop_cluster(REPLICASET_1)
---
...
39 changes: 39 additions & 0 deletions test/misc/fullmesh.test.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
test_run = require('test_run').new()
REPLICASET_1 = { 'storage_1_a', 'storage_1_b' }
REPLICASET_2 = { 'storage_2_a', 'storage_2_b' }
test_run:create_cluster(REPLICASET_1, 'misc')
test_run:create_cluster(REPLICASET_2, 'misc')
util = require('util')
test_run:wait_fullmesh(REPLICASET_1)
test_run:wait_fullmesh(REPLICASET_2)
util.map_evals(test_run, {REPLICASET_1, REPLICASET_2}, 'bootstrap_storage(\'memtx\')')

--
-- gh-83: use fullmesh topology in vshard. Scenario of the test:
-- start writing a tuple on a master. Then switch master. After
-- switch the tuple still should be sent from the slave to a new
-- master.
--

_ = test_run:switch('storage_1_a')
-- Block new requests sending.
box.error.injection.set("ERRINJ_WAL_DELAY", true)
f = fiber.create(function() box.space.test:replace{1, 1} end)
box.space.test:select{}
cfg.sharding[util.replicasets[1]].replicas[util.name_to_uuid.storage_1_b].master = true
cfg.sharding[util.replicasets[1]].replicas[util.name_to_uuid.storage_1_a].master = false
vshard.storage.cfg(cfg, util.name_to_uuid.storage_1_a)
_ = test_run:switch('storage_1_b')
cfg.sharding[util.replicasets[1]].replicas[util.name_to_uuid.storage_1_b].master = true
cfg.sharding[util.replicasets[1]].replicas[util.name_to_uuid.storage_1_a].master = false
vshard.storage.cfg(cfg, util.name_to_uuid.storage_1_b)
box.space.test:select{}
_ = test_run:switch('storage_1_a')
box.error.injection.set("ERRINJ_WAL_DELAY", false)
_ = test_run:switch('storage_1_b')
while box.space.test:count() == 0 do fiber.sleep(0.1) end
box.space.test:select{}

_ = test_run:cmd("switch default")
test_run:drop_cluster(REPLICASET_2)
test_run:drop_cluster(REPLICASET_1)
3 changes: 3 additions & 0 deletions test/misc/master_switch.result
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ cfg.sharding[util.replicasets[1]].replicas[util.name_to_uuid.storage_1_b].master
cfg.sharding[util.replicasets[1]].replicas[util.name_to_uuid.storage_1_a].master = false
---
...
cfg.replication_connect_quorum = 1
---
...
vshard.storage.cfg(cfg, util.name_to_uuid.storage_1_b)
---
...
Expand Down
1 change: 1 addition & 0 deletions test/misc/master_switch.test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ _ = test_run:cmd('start server storage_1_b')
_ = test_run:switch('storage_1_b')
cfg.sharding[util.replicasets[1]].replicas[util.name_to_uuid.storage_1_b].master = true
cfg.sharding[util.replicasets[1]].replicas[util.name_to_uuid.storage_1_a].master = false
cfg.replication_connect_quorum = 1
vshard.storage.cfg(cfg, util.name_to_uuid.storage_1_b)
box.space._bucket:replace({1, vshard.consts.BUCKET.ACTIVE})
box.space.test:insert{1, 1, 2}
Expand Down
10 changes: 6 additions & 4 deletions test/misc/reconfigure.result
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ uris
...
box.cfg.replication
---
- []
- - storage:[email protected]:3301
...
_ = test_run:switch('storage_2_a')
---
Expand All @@ -300,7 +300,8 @@ uris
...
box.cfg.replication
---
- - storage:[email protected]:3304
- - storage:[email protected]:3303
- storage:[email protected]:3304
...
_ = test_run:switch('storage_2_b')
---
Expand All @@ -325,7 +326,8 @@ uris
...
box.cfg.replication
---
- []
- - storage:[email protected]:3303
- storage:[email protected]:3304
...
_ = test_run:switch('storage_3_a')
---
Expand All @@ -350,7 +352,7 @@ uris
...
box.cfg.replication
---
- []
- - storage:[email protected]:3306
...
_ = test_run:switch('router_1')
---
Expand Down
1 change: 1 addition & 0 deletions test/misc/suite.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ core = tarantool
description = Misc tests
script = test.lua
is_parallel = False
release_disabled = fullmesh.test.lua
lua_libs = ../lua_libs/util.lua bad_uuid_config.lua ../../example/localcfg.lua
8 changes: 5 additions & 3 deletions vshard/storage/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1791,9 +1791,11 @@ local function storage_cfg(cfg, this_replica_uuid, is_reload)
-- If a master role of the replica is not changed, then
-- 'read_only' can be set right here.
box_cfg.listen = box_cfg.listen or this_replica.uri
if box_cfg.replication == nil and this_replicaset.master
and not is_master then
box_cfg.replication = {this_replicaset.master.uri}
if not box_cfg.replication then
box_cfg.replication = {}
for uuid, replica in pairs(this_replicaset.replicas) do
table.insert(box_cfg.replication, replica.uri)
end
else
box_cfg.replication = {}
end
Expand Down

0 comments on commit 5292cfe

Please sign in to comment.