Skip to content

Commit

Permalink
Add triggers
Browse files Browse the repository at this point in the history
  • Loading branch information
yngvar-antonsson committed Aug 1, 2023
1 parent 195887f commit 8b3556b
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 38 deletions.
3 changes: 3 additions & 0 deletions cartridge/confapplier.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ local cluster_cookie = require('cartridge.cluster-cookie')
local ClusterwideConfig = require('cartridge.clusterwide-config')
local logging_whitelist = require('cartridge.logging_whitelist')
local invalid_format = require('cartridge.invalid-format')
local sync_spaces = require('cartridge.sync-spaces')

yaml.cfg({
encode_load_metatables = false,
Expand Down Expand Up @@ -558,12 +559,14 @@ local function boot_instance(clusterwide_config)
-- It recovers snapshot
-- Or bootstraps replication
invalid_format.start_check()
sync_spaces.start_check()
local snap1 = hotreload.snap_fibers()

box.cfg(box_opts)
local snap2 = hotreload.snap_fibers()
hotreload.whitelist_fibers(hotreload.diff(snap1, snap2))
invalid_format.end_check()
sync_spaces.end_check()
require('membership.options').SUSPICIOUSNESS = true

local username = cluster_cookie.username()
Expand Down
40 changes: 14 additions & 26 deletions cartridge/issues.lua
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ local failover = require('cartridge.failover')
local confapplier = require('cartridge.confapplier')
local lua_api_proxy = require('cartridge.lua-api.proxy')
local invalid_format = require('cartridge.invalid-format')
local sync_spaces = require('cartridge.sync-spaces')

local ValidateConfigError = errors.new_class('ValidateConfigError')

Expand Down Expand Up @@ -305,33 +306,20 @@ local function list_on_instance(opts)
})
end

if box.ctl.promote ~= nil
and failover.is_leader()
local sync_spaces_list = sync_spaces.spaces_list_str()
if sync_spaces_list ~= ''
and (failover.is_leader()
and (failover.mode() == 'eventual'
or (failover.mode() == 'stateful' and not failover.is_synchro_mode_enabled())) then
local has_sync_spaces = false
local n = 0
for _, tuple in box.space._space:pairs(512, {iterator = 'GE'}) do
n = n + 1
if n % 500 == 0 then
fiber.yield()
end
if tuple.flags.is_sync then
has_sync_spaces = true
break
end
end
if has_sync_spaces then
table.insert(ret, {
level = 'warning',
topic = 'failover',
instance_uuid = instance_uuid,
replicaset_uuid = replicaset_uuid,
message = 'Having sync spaces may cause failover errors. ' ..
'Consider to change failover type to stateful and enable synchro_mode or use ' ..
'raft failover mode'
})
end
or (failover.mode() == 'stateful' and not failover.is_synchro_mode_enabled()))) then
table.insert(ret, {
level = 'warning',
topic = 'failover',
instance_uuid = instance_uuid,
replicaset_uuid = replicaset_uuid,
message = 'Having sync spaces may cause failover errors. ' ..
'Consider to change failover type to stateful and enable synchro_mode or use ' ..
'raft failover mode. Sync spaces: ' .. sync_spaces_list
})
end


Expand Down
29 changes: 17 additions & 12 deletions test/integration/failover_eventual_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ g.before_all = function()
datadir = fio.tempdir(),
use_vshard = true,
server_command = helpers.entrypoint('srv_basic'),
cookie = helpers.random_cookie(),
cookie = 'secret',
replicasets = {
{
alias = 'router',
Expand Down Expand Up @@ -717,23 +717,28 @@ function g.test_sync_spaces_is_prohibited()
box.schema.space.create('test', {if_not_exists = true, is_sync=true})
end)

t.assert_items_equals(helpers.list_cluster_issues(master), {
{
level = 'warning',
topic = 'failover',
message = 'Having sync spaces may cause failover errors. ' ..
'Consider to change failover type to stateful and enable synchro_mode or use ' ..
'raft failover mode',
instance_uuid = master.instance_uuid,
replicaset_uuid = master.replicaset_uuid,
},
})
master:restart()

helpers.retrying({}, function()
t.assert_items_equals(helpers.list_cluster_issues(master), {
{
level = 'warning',
topic = 'failover',
message = 'Having sync spaces may cause failover errors. ' ..
'Consider to change failover type to stateful and enable synchro_mode or use ' ..
'raft failover mode. Sync spaces: test',
instance_uuid = master.instance_uuid,
replicaset_uuid = master.replicaset_uuid,
},
})
end)
end

g.after_test('test_sync_spaces_is_prohibited', function()
cluster:server('storage-1'):exec(function()
box.space.test:drop()
end)
cluster:server('storage-1'):restart()
end)


Expand Down

0 comments on commit 8b3556b

Please sign in to comment.