tarantool/queue

Taken task is not released back to 'ready' after Tarantool reboot

rybakit opened this issue · 8 comments

How to reproduce:

  1. Get into the docker container and add a task:
docker-compose exec tnt1 tarantoolctl connect /var/run/tarantool/tarantool.sock
queue.tube.default:put({test=true})
---
- [0, 'r', {'test': true}]
...
  1. Take a task:
queue.tube.default:take()
---
- [0, 't', {'test': true}]
...
  1. Restart container:
docker-compose restart tnt1
  1. Check task status:
queue.tube.default:peek(0)
---
- [0, 't', {'test': true}]
...

The issue can be reproduced with connectors:

https://github.com/igorcoding/asynctnt-queue:

import asyncio
import asynctnt
import asynctnt_queue
import sys

async def run():
    conn = asynctnt.Connection(host='tnt1', port=3301, username='tnt1', password='tnt1')
    await conn.connect()

    queue = asynctnt_queue.Queue(conn)
    test_tube = queue.tube('default')

    # Retrieve a task from queue
    task = await test_tube.take(1)

    print(task)

    # Restart Tarantool here
    sys.stdin.readline()

    await conn.disconnect()

loop = asyncio.get_event_loop()
loop.run_until_complete(run())

https://github.com/tarantool-php/queue:

<?php

$conn = new \Tarantool\Client\Connection\StreamConnection('tcp://127.0.0.1:3301');
$client = new \Tarantool\Client\Client($conn, new \Tarantool\Client\Packer\PurePacker());
$client->authenticate('tnt1', 'tnt1');

$queue = new \Tarantool\Queue\Queue($client, 'default');
$task = $queue->take(1);

var_dump($task);

readline('Restart Tarantool and press a key to continue');

Here is the simplified instance configuration:

box.cfg {
    listen = 3301,
    log_level = 5
}

local config = {
    user = 'tnt1',
    password = 'tnt1'
}

if not box.schema.user.exists(config.user) then
    box.schema.user.create(config.user, {password = config.password})
    box.schema.user.grant(config.user, 'read,write,execute', 'universe', nil)
end

queue = require('queue')
box.once('foobar:v0.1.0', function()
    queue.create_tube('default', 'fifottl', {if_not_exists = true})
end)

Hmm, what should the solution look like for this?

@Totktonada @LeonidVas What is the status of this issue? Could the fix be reviewed (and hopefully merged) anytime soon?

Sorry, but I can't to do a review of myself). I try to force it.

Sorry, but I can't to do a review of myself). I try to force it.

Firstly, could you add a test case for your patch?

This is a good question.
The test will be require to restart the tarantool instance (with kill -9). As I have understood, it's don't envisaged by queue test concept's and will be look like a crutch. If you have a good example of such test (with an instance restart), please, post it.

I think, it can be done by using of a shell script, but it's look like a crutch in my mind.

I think, it can be done by using of a shell script, but it's look like a crutch in my mind.

Yes, it's separate task. No, we shouldn't use scripts IMO. As a variant we could try to use test-run or luatest that can start and stop tarantool instances.

Let's ask @Totktonada for correct way to check it

I had a conversation with @Totktonada earlier. The current decision - without test (as I understand it).