Skip to content
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## bugfix/replication

* Fixed the election state corruption after an anonymous replica
becomes non-anonymous (gh-11938).
13 changes: 13 additions & 0 deletions src/box/applier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2561,6 +2561,19 @@ applier_f(va_list ap)
* is retrying final join.
*/
applier_register(applier, was_anon);
/*
* It's hard to catch the exact moment when
* instance id settles, for example, it could
* change multiple times during register, but we
* have to configure raft with it before
* `applier_subscribe` starts, because we'll
* start receiving raft messages there.
*/
if (was_anon) {
assert(instance_id != 0);
raft_cfg_instance_id(box_raft(),
instance_id);
}
}
applier_subscribe(applier);
/*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
local t = require('luatest')
local server = require('luatest.server')
local replica_set = require('luatest.replica_set')

local g = t.group()

g.before_each(function(cg)
t.tarantool.skip_if_not_debug()
cg.replica_set = replica_set:new{}
cg.master = cg.replica_set:build_and_add_server({
box_cfg = {
election_mode = 'candidate',
},
alias = 'master',
})
cg.replica = cg.replica_set:build_and_add_server({
box_cfg = {
replication = {
server.build_listen_uri('master', cg.replica_set.id),
},
replication_anon = true,
read_only = true,
},
alias = 'replica',
})
end)

g.after_each(function(cg)
cg.replica_set:drop()
end)

g.test_anon_replica_election_state_is_consistent_after_register = function(cg)
cg.replica_set:start()
cg.replica:update_box_cfg({
replication_anon = false,
})
t.helpers.retrying({}, function()
cg.replica:assert_follows_upstream(cg.master:get_instance_id())
end)
end
Loading