Skip to content

Commit 3e2efcd

Browse files
committed
cfg: check for temporary tubes in replicaset mode
In replicaset mode we cannot use temporary tubes. Data on them will not be replicated and the correct operation of the queue will be disrupted. This patch will not allow creation of the temporary tube if `in_replicaset == true` or will not allow to set `in_replicaset = true` if temporary tubes exists. Follows up #120
1 parent fca68c8 commit 3e2efcd

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

queue/abstract.lua

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,12 @@ function method.create_tube(tube_name, tube_type, opts)
569569
return queue.tube[tube_name]
570570
end
571571

572+
local replicaset_mode = queue.cfg['in_replicaset'] or false
573+
if replicaset_mode and opts.temporary then
574+
log.error("Cannot create temporary tube in replicaset mode")
575+
return
576+
end
577+
572578
local driver = queue.driver[tube_type]
573579
if driver == nil then
574580
error("Unknown tube type " .. tostring(tube_type))
@@ -842,6 +848,23 @@ local function cfg(self, opts)
842848
opts['in_replicaset'] = false
843849
end
844850

851+
-- Temporary spaces are not allowed in replicaset mode.
852+
if opts['in_replicaset'] == true and box.space._queue then
853+
local temp_tubes = ""
854+
for _, tube in box.space._queue:pairs() do
855+
if tube[5].temporary then
856+
temp_tubes = temp_tubes .. ', ' .. tube[1]
857+
end
858+
end
859+
860+
if #temp_tubes ~= 0 then
861+
temp_tubes = temp_tubes:sub(3) -- Cut first ', '.
862+
opts['in_replicaset'] = false
863+
log.error('Queue: cannot set `in_replicaset = true`: '
864+
.. 'temporary tube(s) exists: ' .. temp_tubes)
865+
end
866+
end
867+
845868
-- Check all options before configuring so that
846869
-- the configuration is done transactionally.
847870
for key, val in pairs(opts) do

0 commit comments

Comments
 (0)