Skip to content

Commit a8352f2

Browse files
committed
Allow some fast methods to finish after rebalance started
1 parent 8ea36f9 commit a8352f2

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
77

88
## [Unreleased]
99

10+
### Added
11+
* Implement "safe" mode to prevent writing data to wrong replicaset when vshard rebalance is in progress.
12+
* Auto switch to safe mode when rebalance process starts.
13+
* Manual return to fast mode.
14+
1015
## [1.6.1] - 19-09-25
1116

1217
### Added

crud/common/call.lua

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,27 @@ local CallError = errors.new_class('CallError')
1616

1717
local CALL_FUNC_NAME = 'call_on_storage'
1818
local CRUD_CALL_FUNC_NAME = utils.get_storage_call(CALL_FUNC_NAME)
19-
local CRUD_CALL_FIBER_NAME = CRUD_CALL_FUNC_NAME .. '/'
19+
20+
-- Methods that can continue execution in fast mode when rebalance starts
21+
local safe_mode_allowed_fast_methods = {
22+
CRUD_CALL_FUNC_NAME .. '/fast/' .. utils.get_storage_call('readview_open_on_storage'),
23+
CRUD_CALL_FUNC_NAME .. '/fast/' .. utils.get_storage_call('readview_close_on_storage'),
24+
CRUD_CALL_FUNC_NAME .. '/fast/' .. utils.get_storage_call('select_readview_on_storage'),
25+
CRUD_CALL_FUNC_NAME .. '/fast/' .. utils.get_storage_call('truncate_on_storage'),
26+
CRUD_CALL_FUNC_NAME .. '/fast/' .. utils.get_storage_call('len_on_storage'),
27+
CRUD_CALL_FUNC_NAME .. '/fast/' .. utils.get_storage_call('count_on_storage'),
28+
CRUD_CALL_FUNC_NAME .. '/fast/' .. utils.get_storage_call('get_border_on_storage'),
29+
}
2030

2131
local call = {}
2232

2333
local function call_on_storage_safe(run_as_user, func_name, ...)
24-
fiber.name(CRUD_CALL_FIBER_NAME .. 'safe/' .. func_name)
34+
fiber.name(CRUD_CALL_FUNC_NAME .. '/safe/' .. func_name)
2535
return box.session.su(run_as_user, call_cache.func_name_to_func(func_name), ...)
2636
end
2737

2838
local function call_on_storage_fast(run_as_user, func_name, ...)
29-
fiber.name(CRUD_CALL_FIBER_NAME .. 'fast/' .. func_name)
39+
fiber.name(CRUD_CALL_FUNC_NAME .. '/fast/' .. func_name)
3040
return box.session.su(run_as_user, call_cache.func_name_to_func(func_name), ...)
3141
end
3242

@@ -36,8 +46,17 @@ local function safe_mode_enable()
3646
call_on_storage = call_on_storage_safe
3747

3848
for fb_id, fb in pairs(fiber.info()) do
39-
if string.find(fb.name, CRUD_CALL_FIBER_NAME) then
40-
fiber.kill(fb_id)
49+
if string.find(fb.name, CRUD_CALL_FUNC_NAME .. '/fast/') then
50+
local do_kill = true
51+
for _, allowed_method in ipairs(safe_mode_allowed_fast_methods) do
52+
if fb.name == allowed_method then
53+
do_kill = false
54+
break
55+
end
56+
end
57+
if do_kill then
58+
fiber.kill(fb_id)
59+
end
4160
end
4261
end
4362
end

0 commit comments

Comments
 (0)