Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: align space_index_test with the transactional DDL #157

Merged
merged 1 commit into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Changed

- Updated the 'space_index_test.lua' to drop and recreate the test space
atomically. This prevents the space access failure in the expirationd
task fiber if the `space:drop` function is transactional (#157).

### Fixed

## 1.5.0 - 2023-08-23
Expand Down
13 changes: 13 additions & 0 deletions test/helper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,19 @@ function helpers.memtx_func_index_is_supported()
(major >= 3)
end

function helpers.single_yield_transactional_ddl_is_supported()
local major, minor, patch = helpers.tarantool_version()

-- The issue: https://github.com/tarantool/tarantool/issues/4083
--
-- A limited transactional DDL support has been introduced in 2.2.1, it
-- allows to wrap a single-yield DDL statement set into a transaction if
-- the yielding statement is the first in the transaction.
return (major == 2 and minor == 2 and patch >= 1) or
(major == 2 and minor >= 3) or
(major >= 3)
end

function helpers.error_function()
error("error function call")
end
Expand Down
30 changes: 30 additions & 0 deletions test/unit/space_index_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,39 @@ function g.test_not_stop_after_drop_and_recreate(cg)
end)

helpers.iteration_result = {}

-- This should be atomic to prevent yielding into the expirationd task with
-- partially applied changes (when the old space is dropped but the new one
-- is not created yet).
--
-- The space drop is transactional if the tarantool/taratool#8751 is merged,
-- so it yields on commit. After that point the space is dropped.
--
-- The expirationd task yields on each tuple drop if the task does not have
-- the atomic_iteration option set.
--
-- So without this begin/commit guard the following situation is possible:
-- 1. The expirationd task has started.
-- 2. The task removes one tuple, which causes yield.
-- 3. The current fiber drops the space and yields to the expirationd task.
-- 4. The expirationd task finishes the iteration and checks if the space
-- is vinyl to update the vinyl_assumed_space_len, but the space does
-- not exist anymore, so it fails causing the task restart.

-- Since the test is also executed against old versions of Tarantool, let's
-- only wrap the space drop and recreation into transaction on the versions
-- that support at least single-yield transactional DDL.
if helpers.single_yield_transactional_ddl_is_supported() then
box.begin()
end

cg.case_space:drop()
create_case_space(cg, space_name)

if helpers.single_yield_transactional_ddl_is_supported() then
box.commit()
end

helpers.retrying({}, function()
t.assert_equals(helpers.iteration_result, {{2, "2"}})
end)
Expand Down