Skip to content
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

worker stop after first attempt on db driver #207

Closed
farmani opened this issue Feb 8, 2018 · 12 comments
Closed

worker stop after first attempt on db driver #207

farmani opened this issue Feb 8, 2018 · 12 comments
Assignees
Labels
Milestone

Comments

@farmani
Copy link
Contributor

farmani commented Feb 8, 2018

I see this in supervisor log when an error happen it seems for db driver when an error occurred it cannot attempt next time because of this

2018-02-05 15:00:32 [pid: 10761] - Worker is stopped (0:00:00)
PHP Warning 'yii\base\ErrorException' with message 'sleep() expects parameter 1 to be integer, string given'

in /project/vendor/yiisoft/yii2-queue/src/drivers/db/Queue.php:91

Stack trace:
#0 /project/vendor/yiisoft/yii2-queue/src/cli/Queue.php(108): yii\queue\db\Queue->yii\queue\db\{closure}()
#1 /project/vendor/yiisoft/yii2-queue/src/cli/Queue.php(108): ::call_user_func:{/project/vendor/yiisoft/yii2-queue/src/cli/Queue.php:108}()
#2 /project/vendor/yiisoft/yii2-queue/src/drivers/db/Queue.php(94): yii\queue\db\Queue->runWorker()
#3 /project/vendor/yiisoft/yii2-queue/src/drivers/db/Command.php(68): yii\queue\db\Queue->run()
#4 /project/vendor/yiisoft/yii2/base/InlineAction.php(57): yii\queue\db\Command->actionListen()
#5 /project/vendor/yiisoft/yii2/base/InlineAction.php(57): ::call_user_func_array:{/project/vendor/yiisoft/yii2/base/InlineAction.php:57}()
#6 /project/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams()
#7 /project/vendor/yiisoft/yii2/console/Controller.php(135): yii\queue\db\Command->runAction()
#8 /project/vendor/yiisoft/yii2/base/Module.php(528): yii\queue\db\Command->runAction()
#9 /project/vendor/yiisoft/yii2/console/Application.php(180): yii\console\Application->runAction()
#10 /project/vendor/yiisoft/yii2/console/Application.php(147): yii\console\Application->runAction()
#11 /project/vendor/yiisoft/yii2/base/Application.php(386): yii\console\Application->handleRequest()
#12 /project/yii(20): yii\console\Application->run()
#13 {main}
@samdark
Copy link
Member

samdark commented Feb 8, 2018

I'd find out what the string is before casting it to int...

@samdark samdark added the status:to be verified Needs to be reproduced and validated. label Feb 8, 2018
@samdark
Copy link
Member

samdark commented Feb 8, 2018

Can you log it and check?

@farmani
Copy link
Contributor Author

farmani commented Feb 8, 2018

I think its string "123" because it fetch from db but I will check after work.

@samdark
Copy link
Member

samdark commented Feb 8, 2018

Ah, understood. Yes, seems to be casting problem and solution should be OK.

@samdark samdark removed the status:to be verified Needs to be reproduced and validated. label Feb 8, 2018
@samdark samdark added this to the 2.0.3 milestone Feb 8, 2018
@zhuravljov
Copy link
Member

@farmani I cannot reproduce the bug. Show your command line that starts a worker and throws the exception, please. What PHP are you using?

@farmani
Copy link
Contributor Author

farmani commented Feb 22, 2018

the first exception is in my code but when it want to create the second try in a retryable job this error rised. I think php version is 7.0 but no matter what php version you use in db driver it should happen in all php version.

@zhuravljov
Copy link
Member

Your exception trace shows that sleep() function gets a wrong parameter. The parameter is set as console option, for example:

php yii queue/listen 3

The exception can be shown if you specially set wrong param:

php yii queue/listen abc

Please, show you command option from supervisor configuration.

@farmani
Copy link
Contributor Author

farmani commented Feb 22, 2018

find the issue on the server you right but anyway casting prevent exception and this kind of problems

/usr/bin/php /www/project/yii queue/listen --verbose=1 --col$

@zhuravljov
Copy link
Member

@zhuravljov they ran with supervisord with this command

/usr/bin/php /www/project/yii queue/listen --verbose=1 --color=0

Yes, it is correct command.

I'm not sure that casting will solve the issue, because cause of the bug is still undefined.

@farmani
Copy link
Contributor Author

farmani commented Feb 22, 2018

@zhuravljov cause of bug is obvious in the server supervisord config was like this:

/usr/bin/php /www/project/yii queue/listen --verbose=1 --col$

line break with $ because of copy past its not a bug actually but should throw an invalid param exception or casting may also be a solution too

@zhuravljov
Copy link
Member

zhuravljov commented Feb 22, 2018

OK, understood. But type casting is wrong way, because it doesn't solve the problem, it hides its. For example intval('abcd') returns 0. And listener will work without delay. I have proposed case with param validation. See #208 (comment)

@farmani
Copy link
Contributor Author

farmani commented Feb 22, 2018

@zhuravljov make sense

@zhuravljov zhuravljov self-assigned this Feb 22, 2018
zhuravljov added a commit that referenced this issue Feb 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants