Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rybakit opened this issue Oct 24, 2017 · 8 comments · Fixed by #106
Closed

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

rybakit opened this issue Oct 24, 2017 · 8 comments · Fixed by #106
Assignees
Labels
bug Something isn't working

Comments

@rybakit
Copy link
Contributor

rybakit commented Oct 24, 2017

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)
@aleclarson
Copy link
Contributor

Hmm, what should the solution look like for this?

@Totktonada Totktonada added the bug Something isn't working label Dec 4, 2019
@LeonidVas LeonidVas self-assigned this Dec 11, 2019
LeonidVas added a commit that referenced this issue Dec 18, 2019
If some tasks have been taken and don't released before shutdown
of the tarantool instance (for example: tarantool instance has been killed)
such task go to 'hung' state (noone can take the task now).
So, we must release all taken tasks on start of the queue module.

Fixes: #66
@rybakit
Copy link
Contributor Author

rybakit commented Jan 21, 2020

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

@LeonidVas
Copy link
Contributor

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

@olegrok
Copy link
Contributor

olegrok commented Jan 23, 2020

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?

@LeonidVas
Copy link
Contributor

LeonidVas commented Jan 23, 2020

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.

@LeonidVas
Copy link
Contributor

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

@olegrok
Copy link
Contributor

olegrok commented Jan 23, 2020

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

@LeonidVas
Copy link
Contributor

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

LeonidVas added a commit that referenced this issue Jan 27, 2020
If some tasks have been taken and don't released before shutdown
of the tarantool instance (for example: tarantool instance has been killed)
such task go to 'hung' state (noone can take the task now).
So, we must release all taken tasks on start of the queue module.

Fixes #66
LeonidVas added a commit that referenced this issue Jan 27, 2020
If some tasks have been taken and don't released before shutdown
of the tarantool instance (for example: tarantool instance has been killed)
such task go to 'hung' state (noone can take the task now).
So, we must release all taken tasks on start of the queue module.

Fixes #66
LeonidVas added a commit that referenced this issue Feb 27, 2020
All taken tasks will be released after the server restart

If some tasks have been taken and don't released before shutdown
of the tarantool instance (for example: tarantool instance has been killed)
such task go to 'hung' state (noone can take the task now).
So, we must release all taken tasks on start of the queue module.

Fixes #66
LeonidVas added a commit that referenced this issue Feb 28, 2020
All taken tasks will be released after the server restart

If some tasks have been taken and don't released before shutdown
of the tarantool instance (for example: tarantool instance has been killed)
such task go to 'hung' state (noone can take the task now).
So, we must release all taken tasks on start of the queue module.

Fixes #66
LeonidVas added a commit that referenced this issue Feb 28, 2020
All taken tasks will be released after the server restart

If some tasks have been taken and don't released before shutdown
of the tarantool instance (for example: tarantool instance has been killed)
such task go to 'hung' state (noone can take the task now).
So, we must release all taken tasks on start of the queue module.

Fixes #66
Totktonada pushed a commit that referenced this issue Feb 28, 2020
All taken tasks will be released after the server restart

If some tasks have been taken and don't released before shutdown
of the tarantool instance (for example: tarantool instance has been killed)
such task go to 'hung' state (noone can take the task now).
So, we must release all taken tasks on start of the queue module.

Fixes #66
LeonidVas added a commit that referenced this issue Jul 24, 2020
LeonidVas added a commit that referenced this issue Jul 28, 2020
Totktonada pushed a commit that referenced this issue Jul 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants