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

Merge branch '1.9' into 1.10

parents 8395287e 1d3a6cb0
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,21 @@ local json = require('json')
local private = require('box.internal')
local urilib = require('uri')
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
local default_cfg = {
......@@ -409,7 +424,7 @@ local function load_cfg(cfg)
-- Save new box.cfg
box.cfg = cfg
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()
end
-- Restore box members after initial configuration
......@@ -423,7 +438,7 @@ local function load_cfg(cfg)
__newindex = function(table, index)
error('Attempt to modify a read-only table')
end,
__call = reload_cfg,
__call = locked(reload_cfg),
})
private.cfg_load()
for key, fun in pairs(dynamic_cfg) do
......@@ -439,7 +454,7 @@ local function load_cfg(cfg)
box.schema.upgrade{auto = true}
end
end
box.cfg = load_cfg
box.cfg = locked(load_cfg)
-- gh-810:
-- hack luajit default cpath
......
......@@ -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
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}
---
...
......
......@@ -9,6 +9,16 @@ replication_timeout = box.cfg.replication_timeout
replication_connect_timeout = box.cfg.replication_connect_timeout
box.cfg{replication_timeout=0.05, replication_connect_timeout=0.05, replication={}}
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}
-- 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