diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c9acfb8..482a59d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index f37fb15c..a5488c38 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/crud/common/utils.lua b/crud/common/utils.lua index 2b47bad6..3751070e 100644 --- a/crud/common/utils.lua +++ b/crud/common/utils.lua @@ -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) diff --git a/crud/storage.lua b/crud/storage.lua index 5524574f..b00b1386 100644 --- a/crud/storage.lua +++ b/crud/storage.lua @@ -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, {}) @@ -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 diff --git a/test/unit/not_initialized_test.lua b/test/unit/not_initialized_test.lua index bbe215e1..2e23e5bb 100644 --- a/test/unit/not_initialized_test.lua +++ b/test/unit/not_initialized_test.lua @@ -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