Skip to content
Snippets Groups Projects
Commit 57f71ef0 authored by Дмитрий Кольцов's avatar Дмитрий Кольцов
Browse files

fix(sbroad-cartridge): do not create stored procedures on replicas

Stored procedures creation with "box.schema.func.create" is essentially
an insert into a system space "_func". An attempt to call that API on
a replica (which usually is a RO instance) will result
in failure in role initialization.
parent 3d25005b
No related branches found
No related tags found
1 merge request!1414sbroad import
......@@ -11,8 +11,8 @@ local function init(opts) -- luacheck: no unused args
_G.sbroad.execute = sbroad_router.execute
_G.sbroad.trace = sbroad_router.trace
sbroad_router.init()
sbroad_common.init()
sbroad_router.init(opts.is_master)
sbroad_common.init(opts.is_master)
sbroad_common.init_statistics()
return true
......
......@@ -8,9 +8,9 @@ local function init(opts) -- luacheck: no unused args
_G.sbroad.calculate_bucket_id = sbroad_common.calculate_bucket_id
sbroad_common.init()
sbroad_common.init(opts.is_master)
sbroad_common.init_statistics()
sbroad_storage.init()
sbroad_storage.init(opts.is_master)
return true
end
......
......@@ -2,8 +2,10 @@ local cartridge = require('cartridge')
local checks = require('checks')
local core = require('sbroad.core')
local function init ()
core.init()
local function init (is_master)
if is_master then
core.init()
end
end
local function calculate_bucket_id(values, space_name) -- luacheck: no unused args
......
......@@ -39,16 +39,18 @@ _G.get_sharding_column = function()
return cfg["executor_sharding_column"]
end
local function init()
box.schema.func.create(
'libsbroad.invalidate_coordinator_cache',
{ if_not_exists = true, language = 'C' }
)
box.schema.func.create(
'libsbroad.dispatch_query',
{ if_not_exists = true, language = 'C' }
)
local function init(if_master)
if if_master then
box.schema.func.create(
'libsbroad.invalidate_coordinator_cache',
{ if_not_exists = true, language = 'C' }
)
box.schema.func.create(
'libsbroad.dispatch_query',
{ if_not_exists = true, language = 'C' }
)
end
end
local function invalidate_cache ()
......
......@@ -24,21 +24,23 @@ _G.get_storage_cache_size_bytes = function()
return cfg["storage_cache_size_bytes"]
end
local function init()
box.schema.func.create(
'libsbroad.execute',
{ if_not_exists = true, language = 'C' }
)
box.schema.func.create(
'libsbroad.invalidate_segment_cache',
{ if_not_exists = true, language = 'C' }
)
box.schema.func.create(
'libsbroad.rpc_mock',
{ if_not_exists = true, language = 'C' }
)
local function init(is_master)
if is_master then
box.schema.func.create(
'libsbroad.execute',
{ if_not_exists = true, language = 'C' }
)
box.schema.func.create(
'libsbroad.invalidate_segment_cache',
{ if_not_exists = true, language = 'C' }
)
box.schema.func.create(
'libsbroad.rpc_mock',
{ if_not_exists = true, language = 'C' }
)
end
end
local function invalidate_cache()
......
......@@ -17,8 +17,8 @@ local function init_statistics()
end
local function init()
init_bucket()
init_statistics()
init_bucket()
init_statistics()
end
return {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment