Skip to content

Commit

Permalink
storage: use async bootstrap by default for tarantool 3
Browse files Browse the repository at this point in the history
Closes #412
Part of #415
  • Loading branch information
DifferentialOrange committed Apr 2, 2024
1 parent a24afdf commit d03ede5
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

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

### Fixed
* Working with datetime conditions in case of non-indexed fields or
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ enough access to modify some space, then you need to give access to the user.
You can call `crud.init_storage{async = true}` to bootstrap procedures grants
asynchronously. It is useful in case your application master instances may
start in ro mode (for example, if you use Tarantool 3.x). By default,
synchronous bootstrap is used.
asynchronous bootstrap is used for Tarantool 3.x and
synchronous bootstrap is used for Tarantool 1.10 and 2.x.
All VShard routers should call `crud.init_router()` after `vshard.router.cfg()`
(or enable the `crud-router` role for Cartridge) to make `crud` functions
Expand Down
7 changes: 6 additions & 1 deletion crud/common/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -687,13 +687,18 @@ local function determine_enabled_features()
-- https://github.com/tarantool/tarantool/commit/11f2d999a92e45ee41b8c8d0014d8a09290fef7b
enabled_tarantool_features.box_watch = is_version_ge(major, minor, patch, suffix,
2, 10, 0, 'beta2')

enabled_tarantool_features.tarantool_3 = is_version_ge(major, minor, patch, suffix,
3, 0, 0, nil)
end

determine_enabled_features()

for feature_name, feature_enabled in pairs(enabled_tarantool_features) do
local util_name
if feature_name == 'builtin_merger' then
if feature_name == 'tarantool_3' then
util_name = ('is_%s'):format(feature_name)
elseif feature_name == 'builtin_merger' then
util_name = ('tarantool_has_%s'):format(feature_name)
else
util_name = ('tarantool_supports_%s'):format(feature_name)
Expand Down
9 changes: 8 additions & 1 deletion crud/storage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ local modules_with_storage_api = {
storage_info,
}

local DEFAULT_ASYNC
if utils.is_tarantool_3() then
DEFAULT_ASYNC = true
else
DEFAULT_ASYNC = false
end

local function init_impl()
rawset(_G, utils.STORAGE_NAMESPACE, {})

Expand All @@ -105,7 +112,7 @@ function storage.init(opts)
opts = opts or {}

if opts.async == nil then
opts.async = false
opts.async = DEFAULT_ASYNC
end

if type(box.cfg) ~= 'table' then
Expand Down
2 changes: 1 addition & 1 deletion test/unit/not_initialized_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ end)
pgroup.test_no_vshard_storage_cfg = function(g)
t.assert_error_msg_contains('vshard.storage.cfg() must be called first', function()
g.test_server:exec(function()
require('crud').init_storage()
require('crud').init_storage{async = false}
end)
end)
end
Expand Down

0 comments on commit d03ede5

Please sign in to comment.