Skip to content

Commit bff76e2

Browse files
0x501DLeonidVas
authored andcommitted
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 fd3616c commit bff76e2

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
@@ -577,6 +577,12 @@ function method.create_tube(tube_name, tube_type, opts)
577577
return queue.tube[tube_name]
578578
end
579579

580+
local replicaset_mode = queue.cfg['in_replicaset'] or false
581+
if replicaset_mode and opts.temporary then
582+
log.error("Cannot create temporary tube in replicaset mode")
583+
return
584+
end
585+
580586
local driver = queue.driver[tube_type]
581587
if driver == nil then
582588
error("Unknown tube type " .. tostring(tube_type))
@@ -850,6 +856,23 @@ local function cfg(self, opts)
850856
opts['in_replicaset'] = false
851857
end
852858

859+
-- Temporary spaces are not allowed in replicaset mode.
860+
if opts['in_replicaset'] == true and box.space._queue then
861+
local temp_tubes = ""
862+
for _, tube in box.space._queue:pairs() do
863+
if tube[5].temporary then
864+
temp_tubes = temp_tubes .. ', ' .. tube[1]
865+
end
866+
end
867+
868+
if #temp_tubes ~= 0 then
869+
temp_tubes = temp_tubes:sub(3) -- Cut first ', '.
870+
opts['in_replicaset'] = false
871+
log.error('Queue: cannot set `in_replicaset = true`: '
872+
.. 'temporary tube(s) exists: ' .. temp_tubes)
873+
end
874+
end
875+
853876
-- Check all options before configuring so that
854877
-- the configuration is done transactionally.
855878
for key, val in pairs(opts) do

0 commit comments

Comments
 (0)