Skip to content
Snippets Groups Projects
Commit 52bbfc7d authored by Kirill Yukhin's avatar Kirill Yukhin
Browse files

Merge branch '1.10' into 2.0

parents 84cb1e04 e39b4c19
No related branches found
No related tags found
No related merge requests found
...@@ -5,6 +5,21 @@ local json = require('json') ...@@ -5,6 +5,21 @@ local json = require('json')
local private = require('box.internal') local private = require('box.internal')
local urilib = require('uri') local urilib = require('uri')
local math = require('math') local math = require('math')
local fiber = require('fiber')
-- Function decorator that is used to prevent box.cfg() from
-- being called concurrently by different fibers.
local lock = fiber.channel(1)
local function locked(f)
return function(...)
lock:put(true)
local status, err = pcall(f, ...)
lock:get()
if not status then
error(err)
end
end
end
-- all available options -- all available options
local default_cfg = { local default_cfg = {
...@@ -409,7 +424,7 @@ local function load_cfg(cfg) ...@@ -409,7 +424,7 @@ local function load_cfg(cfg)
-- Save new box.cfg -- Save new box.cfg
box.cfg = cfg box.cfg = cfg
if not pcall(private.cfg_check) then if not pcall(private.cfg_check) then
box.cfg = load_cfg -- restore original box.cfg box.cfg = locked(load_cfg) -- restore original box.cfg
return box.error() -- re-throw exception from check_cfg() return box.error() -- re-throw exception from check_cfg()
end end
-- Restore box members after initial configuration -- Restore box members after initial configuration
...@@ -423,7 +438,7 @@ local function load_cfg(cfg) ...@@ -423,7 +438,7 @@ local function load_cfg(cfg)
__newindex = function(table, index) __newindex = function(table, index)
error('Attempt to modify a read-only table') error('Attempt to modify a read-only table')
end, end,
__call = reload_cfg, __call = locked(reload_cfg),
}) })
private.cfg_load() private.cfg_load()
for key, fun in pairs(dynamic_cfg) do for key, fun in pairs(dynamic_cfg) do
...@@ -439,7 +454,7 @@ local function load_cfg(cfg) ...@@ -439,7 +454,7 @@ local function load_cfg(cfg)
box.schema.upgrade{auto = true} box.schema.upgrade{auto = true}
end end
end end
box.cfg = load_cfg box.cfg = locked(load_cfg)
-- --
-- This makes possible do box.sql.execute without calling box.cfg -- This makes possible do box.sql.execute without calling box.cfg
......
...@@ -23,6 +23,30 @@ box.cfg{replication = {'127.0.0.1:12345', box.cfg.listen}} ...@@ -23,6 +23,30 @@ box.cfg{replication = {'127.0.0.1:12345', box.cfg.listen}}
- error: 'Incorrect value for option ''replication'': failed to connect to one or - error: 'Incorrect value for option ''replication'': failed to connect to one or
more replicas' more replicas'
... ...
-- gh-3606 - Tarantool crashes if box.cfg.replication is updated concurrently
fiber = require('fiber')
---
...
c = fiber.channel(2)
---
...
f = function() fiber.create(function() pcall(box.cfg, {replication = {12345}}) c:put(true) end) end
---
...
f()
---
...
f()
---
...
c:get()
---
- true
...
c:get()
---
- true
...
box.cfg{replication_timeout = replication_timeout, replication_connect_timeout = replication_connect_timeout} box.cfg{replication_timeout = replication_timeout, replication_connect_timeout = replication_connect_timeout}
--- ---
... ...
......
...@@ -9,6 +9,16 @@ replication_timeout = box.cfg.replication_timeout ...@@ -9,6 +9,16 @@ replication_timeout = box.cfg.replication_timeout
replication_connect_timeout = box.cfg.replication_connect_timeout replication_connect_timeout = box.cfg.replication_connect_timeout
box.cfg{replication_timeout=0.05, replication_connect_timeout=0.05, replication={}} box.cfg{replication_timeout=0.05, replication_connect_timeout=0.05, replication={}}
box.cfg{replication = {'127.0.0.1:12345', box.cfg.listen}} box.cfg{replication = {'127.0.0.1:12345', box.cfg.listen}}
-- gh-3606 - Tarantool crashes if box.cfg.replication is updated concurrently
fiber = require('fiber')
c = fiber.channel(2)
f = function() fiber.create(function() pcall(box.cfg, {replication = {12345}}) c:put(true) end) end
f()
f()
c:get()
c:get()
box.cfg{replication_timeout = replication_timeout, replication_connect_timeout = replication_connect_timeout} box.cfg{replication_timeout = replication_timeout, replication_connect_timeout = replication_connect_timeout}
-- gh-3111 - Allow to rebootstrap a replica from a read-only master -- gh-3111 - Allow to rebootstrap a replica from a read-only master
......
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