forked from tarantool/tarantool
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wal: fix failing assertion in box_wait_limbo_acked
Before this patch there was an execution sequence in which the assertion in box_wait_limbo_acked would fail. The assertion is that the lsn of the last entry in limbo is always positive after wal_sync. Fix it. Closes tarantool#9235 NO_DOC=bugfix
- Loading branch information
1 parent
2c422a0
commit 05d0adf
Showing
3 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
changelogs/unreleased/gh-9235-assertion_in_box_wait_limbo_acked.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
## bugfix/core | ||
|
||
* Fixed a bug when the assertion in `box_wait_limbo_acked` would fail. | ||
The assertion is that the lsn of the last entry in limbo is always | ||
positive after `wal_sync` (gh-9235). In the release build, the behavior | ||
does not change except that the statement is now true. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
test/replication-luatest/gh_9235_assertion_in_box_wait_limbo_acked_test.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
local t = require('luatest') | ||
local cluster = require('luatest.replica_set') | ||
local server = require('luatest.server') | ||
|
||
local g = t.group('assertion-in-box-wait-limbo-acked') | ||
-- | ||
-- gh-9235: | ||
-- Assertion in box_wait_limbo_acked. | ||
-- | ||
local wait_timeout = 10 | ||
|
||
local function wait_pair_sync(server1, server2) | ||
-- Without retrying it fails sometimes when vclocks are empty and both | ||
-- instances are in 'connect' state instead of 'follow'. | ||
t.helpers.retrying({timeout = wait_timeout}, function() | ||
server1:wait_for_vclock_of(server2) | ||
server2:wait_for_vclock_of(server1) | ||
server1:assert_follows_upstream(server2:get_instance_id()) | ||
server2:assert_follows_upstream(server1:get_instance_id()) | ||
end) | ||
end | ||
|
||
local function server_wait_wal_is_blocked(server) | ||
server:exec(function(wait_timeout) | ||
t.helpers.retrying({timeout = wait_timeout}, function() | ||
t.assert(box.error.injection.get('ERRINJ_WAL_DELAY')) | ||
end) | ||
end, {wait_timeout}) | ||
end | ||
|
||
local function server_wait_synchro_queue_len_is_equal(server, expected) | ||
server:exec(function(expected, wait_timeout) | ||
t.helpers.retrying({timeout = wait_timeout}, function(expected) | ||
t.assert_equals(box.info.synchro.queue.len, expected) | ||
end, expected) | ||
end, {expected, wait_timeout}) | ||
end | ||
|
||
g.before_each(function(cg) | ||
t.tarantool.skip_if_not_debug() | ||
|
||
cg.cluster = cluster:new({}) | ||
local box_cfg = { | ||
replication = { | ||
server.build_listen_uri('master', cg.cluster.id), | ||
server.build_listen_uri('replica', cg.cluster.id), | ||
}, | ||
election_mode = 'candidate', | ||
replication_timeout = 0.1, | ||
election_fencing_mode='off', | ||
replication_synchro_quorum = 2, | ||
replication_synchro_timeout = 100000, | ||
} | ||
cg.master = cg.cluster:build_and_add_server({ | ||
alias = 'master', | ||
box_cfg = box_cfg | ||
}) | ||
box_cfg.election_mode = 'off' | ||
cg.replica = cg.cluster:build_and_add_server({ | ||
alias = 'replica', | ||
box_cfg = box_cfg | ||
}) | ||
cg.cluster:start() | ||
cg.master:wait_until_election_leader_found() | ||
cg.replica:wait_until_election_leader_found() | ||
cg.master:exec(function() | ||
box.schema.space.create('test', {is_sync = true}) | ||
box.space.test:create_index('pk') | ||
end) | ||
wait_pair_sync(cg.replica, cg.master) | ||
end) | ||
|
||
g.after_each(function(cg) | ||
cg.cluster:drop() | ||
end) | ||
|
||
g.test_assert_last_entry_lsn_is_positive = function(cg) | ||
local f = cg.replica:exec(function() | ||
box.error.injection.set('ERRINJ_WAL_DELAY_COUNTDOWN', 0) | ||
local f = require('fiber').create(function() box.ctl.promote() end) | ||
box.cfg{wal_queue_max_size=1} | ||
f:set_joinable(true) | ||
return f:id() | ||
end) | ||
server_wait_wal_is_blocked(cg.replica) | ||
cg.master:exec(function() | ||
require('fiber').create(function() box.space.test:insert{1} end) | ||
require('fiber').create(function() box.space.test:insert{2} end) | ||
end) | ||
server_wait_synchro_queue_len_is_equal(cg.replica, 1) | ||
cg.replica:exec(function() | ||
box.error.injection.set('ERRINJ_WAL_DELAY_COUNTDOWN', 0) | ||
box.error.injection.set('ERRINJ_WAL_DELAY', false) | ||
end) | ||
server_wait_wal_is_blocked(cg.replica) | ||
cg.replica:exec(function(f) | ||
box.error.injection.set('ERRINJ_WAL_DELAY', false) | ||
require('fiber').find(f):join() | ||
end, {f}) | ||
cg.master:exec(function() | ||
box.cfg{replication_synchro_quorum=1} | ||
end) | ||
server_wait_synchro_queue_len_is_equal(cg.replica, 0) | ||
end |