Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

fifottl/limfifottl: stop() blocks forever while RW, drop() leaks the TTL fiber

未关闭
#262 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
55/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
lua
领域
backend, databases

调研方向

Start in queue/abstract/driver/fifottl.lua, especially the TTL loop and stop-channel setup referenced at lines 171-177 and 200; compare its lifecycle with utubettl. Reproduce the RW stop and dropped-tube cases from the issue, then verify that stop returns, fibers terminate, and dropping a tube leaves no TTL fiber using the supplied checks.

由索引模型根据 Issue 内容生成。

描述

Environment: queue master (07fd732), Tarantool 3.8.0 (also the same code in 1.5.0). memtx.

Summary

fifottl (and therefore limfifottl) creates its stop channel as an unbuffered fiber.channel() (fifottl.lua#L200), but the TTL fiber only reads it in the box.info.ro == true branch (fifottl.lua#L171-L177). So:

  1. tube.raw:stop() called while the instance is RW blocks the caller forever.
  2. fifottl has no method.drop, so tube:drop() never calls stop() at all: the space is dropped and the TTL fiber leaks, one per dropped tube. After the instance becomes RO the leaked fibers sit in the sync_chan:get(0.1) poll loop forever.
  3. utubettl uses fiber.channel(1) so its stop() returns, but the fiber keeps running in RW; utubettl's drop() then makes it crash on the dropped space (attempt to index field 'watch' (a nil value)).

Repro

local fiber = require('fiber')
box.cfg{}
local queue = require('queue')

-- 1. stop() blocks while RW
local tube = queue.create_tube('t', 'fifottl')
local done = false
fiber.create(function() tube.raw:stop(); done = true end)
fiber.sleep(1)
print('fifottl raw:stop() returned within 1s:', done)   -- false (utubettl: true)

-- 2. drop() leaks the fiber
local function ttl_fibers()
    local n = 0
    for _, f in pairs(fiber.info()) do if f.name == 'fifottl' then n = n + 1 end end
    return n
end
local before = ttl_fibers()
for i = 1, 3 do queue.create_tube('leak_' .. i, 'fifottl'):drop() end
fiber.sleep(0.5)
print('fifottl fibers leaked by 3 drops:', ttl_fibers() - before)   -- 3

Output on master:

fifottl raw:stop() returned within 1s:  false
fifottl fibers leaked by 3 drops:       3

Expected

stop() returns in both RW and RO mode and the fiber actually terminates; drop() stops the fiber before dropping the space (as utubettl tries to do), and does not leave the fiber running against a dropped space.

Suggested fix

Check a stop flag (or the channel with a zero timeout) in the RW branch of the loop as well, make stop() wait for the fiber to finish before clearing self.fiber, and add method.drop to fifottl that calls stop() first. fifottl should also use a buffered channel like utubettl so stop() cannot block the state machine fiber.

主要语言
Lua
星标
244
派生
56
平均合并
6 天 8 小时
30 天内合并 PR
1

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

tarantool/queue 的其他 Issue

查看 tarantool/queue 的全部 Issue

相似的 Issue

更多 Lua Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。