File tree Expand file tree Collapse file tree 5 files changed +58
-34
lines changed Expand file tree Collapse file tree 5 files changed +58
-34
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,17 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
12
12
* Fixed error for partial result option if field contains box.NULL.
13
13
* Fixed incorrect `` crud `` results during reverse pagination
14
14
without specifying `` batch_size `` .
15
+ * Fixed crud roles reload:
16
+ * before this patch reload wasn't fair - reloading ` tuple.merger `
17
+ and ` tuple.keydef ` modules failed, and crud started to use
18
+ ` crud.select.compat.select_old ` module with naive merger implementation;
19
+ * fair reloading ` tuple.merger ` and ` tuple.keydef ` led to the error that was
20
+ fixed by caching loaded module in the special global variable not cleaned
21
+ on reloading roles;
22
+ * ability of using ` tuple.merger ` and ` tuple.keydef ` modules now is checked
23
+ by calling ` package.search ` , built-in ` merger ` and ` keydef ` modules are used
24
+ if present in ` package.loaded ` . It allows to avoid ignoring errors on checking
25
+ modules existing via ` pcall(require, '<module_name>') ` .
15
26
16
27
### Added
17
28
Original file line number Diff line number Diff line change
1
+ local log = require (' log' )
2
+
3
+ local compat = {}
4
+
5
+ function compat .require (module_name , builtin_module_name )
6
+ local module_cached_name = string.format (' __crud_%s_cached' , module_name )
7
+
8
+ local module
9
+
10
+ local module_cached = rawget (_G , module_cached_name )
11
+ if module_cached ~= nil then
12
+ module = module_cached
13
+ elseif package .search (module_name ) then
14
+ -- we don't use pcall(require, modile_name) here because it
15
+ -- leads to ignoring errors other than 'No LuaRocks module found'
16
+ log .info (' %q module is used' , module_name )
17
+ module = require (module_name )
18
+ else
19
+ log .info (' %q module is not found. Built-in %q is used' , module_name , builtin_module_name )
20
+ module = require (builtin_module_name )
21
+ end
22
+
23
+ rawset (_G , module_cached_name , module )
24
+
25
+ local hotreload = package.loaded [' cartridge.hotreload' ]
26
+ if hotreload ~= nil then
27
+ hotreload .whitelist_globals ({module_cached_name })
28
+ end
29
+
30
+ return module
31
+ end
32
+
33
+ return compat
Original file line number Diff line number Diff line change 1
- local log = require (' log' )
2
1
local msgpack = require (' msgpack' )
3
2
4
3
local comparators = require (' crud.compare.comparators' )
5
4
local collations = require (' crud.common.collations' )
6
5
7
- local keydef_lib
8
-
9
- if pcall (require , ' tuple.keydef' ) then
10
- keydef_lib = require (' tuple.keydef' )
11
- elseif pcall (require , ' keydef' ) then
12
- log .info (' Impossible to load "tuple-keydef" module. Built-in "keydef" is used' )
13
- keydef_lib = require (' key_def' )
14
- else
15
- error (string.format (' Seems your Tarantool version (%q' ..
16
- ' ) does not support "tuple-keydef" or "keydef" modules' , _TARANTOOL ))
17
- end
6
+ local compat = require (' crud.common.compat' )
7
+ local keydef_lib = compat .require (' tuple.keydef' , ' key_def' )
18
8
19
9
-- As "tuple.key_def" doesn't support collation_id
20
10
-- we manually change it to collation
Original file line number Diff line number Diff line change @@ -9,18 +9,18 @@ local SelectError = errors.new_class('SelectError')
9
9
10
10
local select_module
11
11
12
- -- "merger" segfaults here
13
- -- See https://github.com/tarantool/tarantool/issues/4954
14
12
if ' 2' <= _TARANTOOL and _TARANTOOL <= ' 2.3.3' then
13
+ -- "merger" segfaults here
14
+ -- See https://github.com/tarantool/tarantool/issues/4954
15
+ select_module = require (' crud.select.compat.select_old' )
16
+ elseif not package .search (' tuple.merger' ) and package.loaded [' merger' ] == nil then
17
+ -- we don't use pcall(require, modile_name) here because it
18
+ -- leads to ignoring errors other than 'No LuaRocks module found'
19
+
20
+ -- "merger" isn't supported here
15
21
select_module = require (' crud.select.compat.select_old' )
16
22
else
17
- -- Try to require built-in or external merger
18
- local ok , module = pcall (require , ' crud.select.compat.select' )
19
- if ok then
20
- select_module = module
21
- else
22
- select_module = require (' crud.select.compat.select_old' )
23
- end
23
+ select_module = require (' crud.select.compat.select' )
24
24
end
25
25
26
26
local function make_cursor (data )
Original file line number Diff line number Diff line change 1
1
local buffer = require (' buffer' )
2
2
local msgpack = require (' msgpack' )
3
- local log = require (' log' )
4
3
local ffi = require (' ffi' )
5
4
local call = require (' crud.common.call' )
6
5
7
- local Keydef = require (' crud.compare.keydef' )
8
-
9
- local merger_lib
6
+ local compat = require (' crud.common.compat' )
7
+ local merger_lib = compat .require (' tuple.merger' , ' merger' )
10
8
11
- if pcall (require , ' tuple.merger' ) then
12
- merger_lib = require (' tuple.merger' )
13
- elseif pcall (require , ' merger' ) then
14
- log .info (' Impossible to load "tuple-merger" module. Built-in "merger" is used' )
15
- merger_lib = require (' merger' )
16
- else
17
- error (string.format (' Seems your Tarantool version (%q' ..
18
- ' ) does not support "tuple-merger" or "merger" modules' , _TARANTOOL ))
19
- end
9
+ local Keydef = require (' crud.compare.keydef' )
20
10
21
11
local function bswap_u16 (num )
22
12
return bit .rshift (bit .bswap (tonumber (num )), 16 )
You can’t perform that action at this time.
0 commit comments