tarantool / tarantool/tarantool
Shutdown is graceful, but not polite
Nobody has claimed this yet.
- Dominant language
- Lua
- Stars
- 3.7k
- Forks
- 419
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 88
Description
Problem statement
Starting from the 3.1 tarantool cancels user's fibers before shutdown (bf620650c429d0b6c0bae8588f54ea56a0299fd6). Also, it forbids creating of new user fibers during the shutdown (d40ce0fa028a2ee54574ede00b035b9ac66277b7) -- fiber.new() raises an error in the case.
In both cases a user receives an error with the 'fiber is cancelled' message, without any details why it is cancelled.
In some circumstances, it is not obvious why this error appears. A user needs to know how shutdown is performed to guess that the error is related to the graceful shutdown process.
I propose to add a reason of cancellation to this error message. For example:
fiber is cancelled: tarantool goes to shutdown
fiber is cancelled: can't create a new fiber when tarantool goes to shutdown
I also think that the cancellation reason would be a good addition for the fiber's Lua API:
<fiber object>:cancel(reason)
Reproducer
#!/usr/bin/env tarantool
local fiber = require('fiber')
-- Start the graceful shutdown.
fiber.new(os.exit)
pcall(fiber.yield)
-- Attempt to create a new fiber.
local ok, res = pcall(fiber.new, function() end)
print(ok, res)
$ tarantool t.lua
false fiber is cancelled
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Lua reproducer in the issue and the fiber cancellation and shutdown behavior it demonstrates. Trace the fiber Lua API entry points for cancellation, shutdown-triggered cancellation, and new-fiber creation; done means cancellation errors expose the relevant reason and the proposed cancel(reason) API behavior is covered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100