Skip to content

drivers: fix utube kick in the ready buffer mode - #258

Merged
Col-Waltz merged 1 commit into
masterfrom
bigbes/gh-256-utube-kick-ready-buffer
Sep 8, 2026
Merged

drivers: fix utube kick in the ready buffer mode#258
Col-Waltz merged 1 commit into
masterfrom
bigbes/gh-256-utube-kick-ready-buffer

Conversation

@bigbes

@bigbes bigbes commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Two defects in method.kick() of the utube driver, both in the 'ready_buffer' storage mode. utubettl does the same thing correctly via update_ready().

  1. When the utube had no entry in the ready buffer, kick() called put_ready(self, task[3]) while the helper is put_ready(self, id, utube). The utube name was passed as the task id and the utube became nil, so the insert failed on the space format and the error was swallowed by the pcall inside put_ready(). The kicked task stayed READY but was never returned by take(), because take_ready() only looks at the ready buffer.

  2. When the utube already had a younger task in the buffer, kick() replaced it with insert({task[1], task[2]}), that is {id, status} instead of {id, utube}. The status string landed in the utube field, so the buffer no longer had an entry under the real utube name and a later put() added a second one. With two entries for one utube the driver could take two tasks of the same utube at once, which breaks the main utube guarantee, and take_ready() could spin forever on an entry whose utube already had a TAKEN task.

Introduce update_ready() mirroring the utubettl helper and use it in kick().

Also commit the transaction before the early returns of kick(): with no buried tasks kick() returned while the transaction opened by begin_if_not_in_txn() was still running, and it leaked into whatever the caller fiber did next. This part is within the scope of #231.

Closes #256

@oleg-jukovec oleg-jukovec left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the patch. Please, fix comments.

Comment thread t/260-utube-kick.t Outdated
Comment thread t/260-utube-kick.t Outdated
@oleg-jukovec
oleg-jukovec requested a review from Col-Waltz August 28, 2026 13:09
@bigbes
bigbes force-pushed the bigbes/gh-256-utube-kick-ready-buffer branch from 92c09fb to 9137062 Compare September 1, 2026 12:07
Two defects in method.kick() of the utube driver, both in the
'ready_buffer' storage mode. utubettl does the same thing correctly via
update_ready().

1. When the utube had no entry in the ready buffer, kick() called

       put_ready(self, task[3])

   while the helper is put_ready(self, id, utube). The utube name was
   passed as the task id and the utube became nil, so the insert failed
   on the space format and the error was swallowed by the pcall inside
   put_ready(). The kicked task stayed READY but was never returned by
   take(), because take_ready() only looks at the ready buffer.

2. When the utube already had a younger task in the buffer, kick()
   replaced it with

       self.space_ready_buffer:insert({task[1], task[2]})

   that is {id, status} instead of {id, utube}. The status string landed
   in the utube field, so the buffer no longer had an entry under the
   real utube name and a later put() added a second one. With two entries
   for one utube the driver could take two tasks of the same utube at
   once, which breaks the main utube guarantee, and take_ready() could
   spin forever on an entry whose utube already had a TAKEN task.

Introduce update_ready() mirroring the utubettl helper and use it in
kick().

Also commit the transaction before the early returns of kick(): with no
buried tasks kick() returned while the transaction opened by
begin_if_not_in_txn() was still running, and it leaked into whatever the
caller fiber did next. This part is within the scope of #231.

Closes #256
@Col-Waltz
Col-Waltz force-pushed the bigbes/gh-256-utube-kick-ready-buffer branch from 9137062 to d727b2f Compare September 8, 2026 09:43
@Col-Waltz
Col-Waltz merged commit 0f1b8fa into master Sep 8, 2026
22 of 23 checks passed
@Col-Waltz
Col-Waltz deleted the bigbes/gh-256-utube-kick-ready-buffer branch September 8, 2026 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

utube: kick() corrupts the ready buffer in the ready_buffer storage mode

3 participants