tarantool / queue

Create task queues, add and take jobs, monitor failed tasks
Other
234 stars 52 forks source link

api: fix `INIT` state stuck #227

Closed DerekBum closed 3 months ago

DerekBum commented 3 months ago

Sometimes, instance could enter the queue initialization while still not running (for example, left in the orphan mode). This resulted in "lazy start". But Tarantool does not call box.cfg {} after leaving orphan mode, so queue could stuck in the INIT state.

Now if the instance is read-only, separate fiber is watching for updates of its mode.

Note that this fix works only for Tarantool versions >= 2.10.0. This is because of used watchers.

Closes #226

DerekBum commented 3 months ago

The wait and the queue initialization could be done in a background as it is done by box.cfg wrapper now.

Tarantool does not call box.cfg {} upon exiting the orphan mode. Or are you suggesting to run a fiber in a background, that will check status of the instance. And if the orphan mode changes, it updates the status?

oleg-jukovec commented 3 months ago

The wait and the queue initialization could be done in a background as it is done by box.cfg wrapper now.

Tarantool does not call box.cfg {} upon exiting the orphan mode. Or are you suggesting to run a fiber in a background, that will check status of the instance. And if the orphan mode changes, it updates the status?

Yes, it is. When the status check will success - initialize the instance in a background.

DerekBum commented 3 months ago

Updated the code. Now watcher is run in a different fiber, without blocking init function. Note that now this fix only works for Tarantool versions >= 2.10.0. On newer versions this bug will still be present.