tarantool / tarantool/queue

driver: possible data races in `kick` method

Open
#231 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

2sp bug
Dominant language
Lua
Stars
244
Forks
56
PR merge metrics
No merged PRs in 30d

Description

kick method is used to unbury several tasks in the tube. After analyzing this method for drivers fifo, fifottl, utube, utubettl, I came to the conclusion, that it still possible to get a data race and incorrect, unexpected result.

https://github.com/tarantool/queue/blob/aa7c092a1f2ac80d3cfc63c75595d10c5a95c908/queue/abstract/driver/fifo.lua#L158-L173

We take a task with minimal task_id and BURIED status. After that we are updating it, commiting. But lua can also yield before WAL write. So this very task could also be taken in a parallel kick call for the second time.

Possible fix: do changes inside a transaction, like in put, take methods. But there is a subtle point here (which is described in a comment below).
https://github.com/tarantool/queue/blob/aa7c092a1f2ac80d3cfc63c75595d10c5a95c908/queue/abstract/driver/fifo.lua#L101-L117

Contributor guide

No contributing guide indexed for this repository

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

Start with queue/abstract/driver/fifo.lua lines 158-173 and trace how kick selects and updates buried tasks across fifo, fifottl, utube, and utubettl. Compare this with the transaction handling in put and take at lines 101-117, including the noted subtle point. Done means concurrent kick calls cannot select the same task or produce an incorrect result.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
backend, distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.