Ayyanar G
Ayyanar G

Reputation: 1545

Yii background process issue

I am using Yii extension runactions to run background processes, I'm trying to update bulk records (6000) as background process but only around 2500 records only updated in DB !!! I am not getting any error in log, its related to interval or timeout problem ?

I try to change interval in runactions but there is no effect, can anyone please help me in sort out this issue?

Upvotes: 0

Views: 600

Answers (1)

Roberto Braga
Roberto Braga

Reputation: 559

This extension execute the background job at http level so you must manage the script max-execution-time, I don't think this extension take care of it. In case of command line execution max-execution-time does not apply.

http://php.net/manual/en/info.configuration.php#ini.max-execution-time

Usually for long process, rather than disable the tiemout, I increment it in the cycle, something like this:

while ($i <= 10) {
    my_complex_update_query();
    echo "Timeout is : " . ini_get('max_execution_time') . " sec.<br>";
    set_time_limit(ini_get('max_execution_time') + 1);    
    echo "NEW Timeout is : " . ini_get('max_execution_time') . " sec.<br>";
    $i++;
}

This increment the time limit adding 1 sec at every cycle, obviously you must adapt it to your need like add 1 sec every 10 cycle. In this way if the script get stuck for some reason it will timeout anyway and does not hang in memory.

Consider that external call (like database query, exec of system call...) are not counted in the script execution time. So if your script is at 5 sec of execution, you perform a query that take 2 min to execute, when the script goes at the following instruction the execution time is still 5 sec not 2 min + 5 sec.

Upvotes: 1

Related Questions