Skip to content

Commit

Permalink
Merge dbbdddc into b52298f
Browse files Browse the repository at this point in the history
  • Loading branch information
mkostoevr committed Sep 15, 2023
2 parents b52298f + dbbdddc commit 2dc11d5
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
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.

### 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

0 comments on commit 2dc11d5

Please sign in to comment.