Skip to content

Commit 0a352fe

Browse files
storage: use async bootstrap by default for Tarantool 3
Closes #412 Part of #415
1 parent 76f94a3 commit 0a352fe

File tree

5 files changed

+18
-4
lines changed

5 files changed

+18
-4
lines changed

CHANGELOG.md

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

1313
### Changed
1414
* Explicitly forbid datetime interval conditions (#373).
15+
* Storage initialization is now asynchronous by default for Tarantool 3.0+ (#412).
1516

1617
### Fixed
1718
* Working with datetime conditions in case of non-indexed fields or

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ enough access to modify some space, then you need to give access to the user.
9393
You can call `crud.init_storage{async = true}` to bootstrap procedures grants
9494
asynchronously. It is useful in case your application master instances may
9595
start in ro mode (for example, if you use Tarantool 3.x). By default,
96-
synchronous bootstrap is used.
96+
asynchronous bootstrap is used for Tarantool 3.x and
97+
synchronous bootstrap is used for Tarantool 1.10 and 2.x.
9798

9899
All VShard routers should call `crud.init_router()` after `vshard.router.cfg()`
99100
(or enable the `crud-router` role for Cartridge) to make `crud` functions

crud/common/utils.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,13 +687,18 @@ local function determine_enabled_features()
687687
-- https://github.com/tarantool/tarantool/commit/11f2d999a92e45ee41b8c8d0014d8a09290fef7b
688688
enabled_tarantool_features.box_watch = is_version_ge(major, minor, patch, suffix,
689689
2, 10, 0, 'beta2')
690+
691+
enabled_tarantool_features.tarantool_3 = is_version_ge(major, minor, patch, suffix,
692+
3, 0, 0, nil)
690693
end
691694

692695
determine_enabled_features()
693696

694697
for feature_name, feature_enabled in pairs(enabled_tarantool_features) do
695698
local util_name
696-
if feature_name == 'builtin_merger' then
699+
if feature_name == 'tarantool_3' then
700+
util_name = ('is_%s'):format(feature_name)
701+
elseif feature_name == 'builtin_merger' then
697702
util_name = ('tarantool_has_%s'):format(feature_name)
698703
else
699704
util_name = ('tarantool_supports_%s'):format(feature_name)

crud/storage.lua

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ local modules_with_storage_api = {
7878
storage_info,
7979
}
8080

81+
local DEFAULT_ASYNC
82+
if utils.is_tarantool_3() then
83+
DEFAULT_ASYNC = true
84+
else
85+
DEFAULT_ASYNC = false
86+
end
87+
8188
local function init_impl()
8289
rawset(_G, utils.STORAGE_NAMESPACE, {})
8390

@@ -94,7 +101,7 @@ function storage.init(opts)
94101
opts = opts or {}
95102

96103
if opts.async == nil then
97-
opts.async = false
104+
opts.async = DEFAULT_ASYNC
98105
end
99106

100107
if type(box.cfg) ~= 'table' then

test/unit/not_initialized_test.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ end)
9898
pgroup.test_no_vshard_storage_cfg = function(g)
9999
t.assert_error_msg_contains('vshard.storage.cfg() must be called first', function()
100100
g.test_server:exec(function()
101-
require('crud').init_storage()
101+
require('crud').init_storage{async = false}
102102
end)
103103
end)
104104
end

0 commit comments

Comments
 (0)