tarantool / tarantool/tarantool

Name is not reset for iproto fibers between requests

Open
#12,198 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Lua
Stars
3.7k
Forks
419
Avg merge
1d 23h
Merged PRs (30d)
88

Description

Iproto has fiber pool, limited with net_msg_max value. The problem here is that when some fiber sets a name and exits, the other request in the future may take the same fiber and will have the name, set by previous request, even though, the current one did nothing.

Here's the reproducer:

box.cfg{listen = 3301, net_msg_max = 100}

fiber = require('fiber')
c = require('net.box').connect(3301)

c:eval('fiber.self():name("test-name")')

-- After some time we encounter the fiber with the same name, even though
-- we didn't set the name for it.
while c:eval('return fiber.self():name() ~= "test-name"') do
    fiber.yield()
end

assert(false)

This may be the problem, since user assumes, that the fiber is clean, when new request comes. E.g. if user decides to cancel the fibers based on their name, it will have to reset the fiber names back at the end of function execution, in order not to cancel some other request.


When recycling the fibers on local instance we properly clean the state of the fibers:

https://github.com/tarantool/tarantool/blob/0ccd7fe7708338ca3a7157de0622fcd5e8efb386/src/lib/core/fiber.c#L1065

It seems, the state of fibers should be cleaned between requests in iproto fiber pool.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read the fiber cleanup logic at src/lib/core/fiber.c#L1065, then trace how the iproto fiber pool recycles fibers between requests. Use the Lua reproducer in the issue to observe the leaked name; done means a later request cannot see the previous request's fiber name.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.