excessive PHPJOB jobs

General discussion on Zend Core for IBM System i
timo_karvinen
Posts: 82
Joined: Wed Aug 12, 2009 7:58 am
Location: Tampere, Finland
Contact:

excessive PHPJOB jobs

Post by timo_karvinen » Wed Aug 12, 2009 9:12 am

We have updated our Zend Core to the latest 2.6.4 which says on release notes (well for 2.6.3 to be exact) that problem with I5_OPTIONS_IDLE_TIMEOUT not closing PHPJOBs should be fixed.

Well the jobs still don't seem to ever end. Still all the connections created with pconnect are active on wrkusrjob after days even when IDLE_TIMEOUT has been set to couple of minutes.

On a related note. If one refreshes a page on a browser in rapid succession, and that page makes pconnect on php script, it creates new connection about as much as you keep pressing refresh. Well this is kind of to be expected since the last request is still going on and the job is not free for another, but connection seem to be piling up and even after the old jobs should have finished their task, new jobs are still created and old ones are not reused. Well wether this observation is right or not, the problem is that anyone could basically create unlimited number of jobs by just sitting on the browser refresh button. So my question is, is there a way to hard limit creating of new jobs to some value so at some point new ones wont be created even if there are no free ones.

This excessive creation of new jobs with pconnects combined with the IDLE_TIMEOUT seemingly not working isn't good, since there can be lots of unnecessary PHPJOBs just stiting there until the machine/subsystem restarts.

scottgcampbell
Posts: 187
Joined: Wed Apr 22, 2009 2:29 pm
Location: Edmonton, AB, Canada

Re: excessive PHPJOB jobs

Post by scottgcampbell » Wed Aug 12, 2009 3:16 pm

Do you have an example script that does this?
Are you using i5_pconnect or i5_connect? If you are using i5_connect then try i5_pconnect http://files.zend.com/help/Zend-Core-i5 ... or_api.htm

I'm running a website that has hundreds of users (not that big really) and I only see 10-20 PHPJOBs at any given time, but I haven't setup the I5_OPTIONS_IDLE_TIMEOUT yet.

Scott

timo_karvinen
Posts: 82
Joined: Wed Aug 12, 2009 7:58 am
Location: Tampere, Finland
Contact:

Re: excessive PHPJOB jobs

Post by timo_karvinen » Thu Aug 13, 2009 8:01 am

Well I don't have any specific script because it's any script that uses pconnect and i5_program_call.

Yes I am using i5_pconnect for these, the problem is specifically with i5_pconnect, because i5_connect does destroy the jobs after the script execution ends.

I should mention that I don't use i5_pclose anywhere in the script. Because the functionality that we are after is that jobs created with pconnect stay up for like several hours or so, but they should be destroyed after this period of inactivity has elapsed, so the joblist doesn't get cluttered with tens or hundreds of rogue phpjobs. That's why I want to use IDLE_TIMEOUT, so the jobs stay up when needed, but if too many jobs were created at one point and don't get used anymore for a period of time, we can get rid of them.

Your situation doesn't sound like what I described, unless these hundreds of users are using the scripts at the same time. The question is about tens or so page reloads within seconds, which means tens or so i5_program_calls within seconds. Can you try to reload a page with script that makes i5_pconnect and i5_program_call(s) several times in rapid succession and see what happens?

scottgcampbell
Posts: 187
Joined: Wed Apr 22, 2009 2:29 pm
Location: Edmonton, AB, Canada

Re: excessive PHPJOB jobs

Post by scottgcampbell » Thu Aug 13, 2009 4:40 pm

I can't recreate what you are describing. I have a page that has both SQL and program calls, and I can refresh it constantly and I only get one PHPJOB, if I use multiple browsers I get more jobs. Can you post a sample script that causes this on your system and I'll see if I get the same results.

Thanks
Scott

timo_karvinen
Posts: 82
Joined: Wed Aug 12, 2009 7:58 am
Location: Tampere, Finland
Contact:

Re: excessive PHPJOB jobs

Post by timo_karvinen » Fri Aug 14, 2009 9:56 am

Well here's sample script just for testing this situation. If one keeps refreshing this php-page on browser (refresh before the old execution has ended), more PHPJOBs and ZENDCOREAPs will be created. Well at least on our AS/400. Also even with the TIMEOUT set to 30 seconds, those jobs never die.

Code: Select all

<?php

// set TIMEOUT to 30 seconds
$options = array (I5_OPTIONS_IDLE_TIMEOUT => '30');

// make connection with NOBODY to localhost
$conn = i5_pconnect ( '', '', '', $options );
		
// QCMDEXC should be found on every AS/400
$program = ('*LIBL/QCMDEXC');
		
$plist = array ( 
	array ( 'name' => 'command', 'io' => I5_IN, 'type' => I5_TYPE_CHAR, 'length' => '50' ), 
	array ( 'name' => 'length', 'io' => I5_IN, 'type' => I5_TYPE_PACKED, 'length' => '15.5' ) 
);
		
$inParms = array ('command' => 'DSPLIB LIB(QGPL) OUTPUT(*PRINT)', 'length' => 50);
$outParms = array ('command' => 'command', 'length' => 'length');

$prepare = i5_program_prepare ( $program, $plist );
i5_program_call ( $prepare, $inParms, $outParms );
i5_program_close ( $prepare );
		
?>

scottgcampbell
Posts: 187
Joined: Wed Apr 22, 2009 2:29 pm
Location: Edmonton, AB, Canada

Re: excessive PHPJOB jobs

Post by scottgcampbell » Fri Aug 14, 2009 5:08 pm

I tried your script and while I was able to get a lot (I couldn't get more than 10 no matter how hard I tried) of PHPJOBs I did see them being reused.
Like you however I did not see them being cleaned up after the I5_OPTIONS_IDLE_TIMEOUT of 30 seconds, in fact they were never cleaned up. I would open a ticket with ZEND to see if they can determine why the timeout isn't working. If you get a resolution let us know.

Thanks
Scott

timo_karvinen
Posts: 82
Joined: Wed Aug 12, 2009 7:58 am
Location: Tampere, Finland
Contact:

Re: excessive PHPJOB jobs

Post by timo_karvinen » Mon Aug 17, 2009 9:27 am

I did send support ticket to Zend about this. We will see what they have to say, hopefully soon.

darkluke980
Posts: 61
Joined: Sat Mar 28, 2009 8:31 pm
Location: Italy
Contact:

Re: excessive PHPJOB jobs

Post by darkluke980 » Mon Aug 24, 2009 9:16 pm

Hi,

Zend support say .. "To use the timeout feature, please set up a private connection."

is not a good solution .. may be someone can develope some fix. If someone is interesting, i have an RPG batch program that close automatically job at port 6078 after xxxx minutes of timeout.

This is an example with I5_OPTIONS_IDLE_TIMEOUT + I5_OPTIONS_PRIOVATE_CONNECTION that run.

<?php

session_start();

if (isset($_SESSION['connectionID'])) {
$conId = $_SESSION['connectionID'];
echo "Connection ID is $conId<BR>";
} else {
$conId = 0;
echo "No connection ID stored.<BR>";
}

// set TIMEOUT to 30 seconds
$options = array (I5_OPTIONS_PRIVATE_CONNECTION => $conId,
I5_OPTIONS_IDLE_TIMEOUT => '150',
I5_OPTIONS_JOBNAME => "TIMEOUT");

// make connection with NOBODY to localhost
$conn = i5_pconnect ( '', '', '', $options );
if (is_bool($conn) && $retcon == FALSE) {
$errorTab = i5_error();
if ($errorTab['cat'] == 9 && $errorTab['num'] == 285){
echo "Connection ID no longer active<BR>";
$_SESSION['connectionID'] = 0;
die;
} else
print_r($errorTab);
$_SESSION['connectionID'] = 0;
die;
}

if ($conId == 0){
$ret = i5_get_property(I5_PRIVATE_CONNECTION, $conn);
if (is_bool($ret) && $ret == FALSE) {
$errorTab = i5_error();
print_r($errorTab);
} else {
// Connection ID is stored in session variable
$_SESSION['connectionID'] = $ret;
$conId = $ret;
}

}
// Add job logging
if (i5_command("CHGJOB",array("LOG" => "4 00 *SECLVL", "LOGCLPGM" => "*YES"),array(), $conn)) {
} else {
echo "Error =".i5_errormsg();
}

// Display the job ID. This makes it easy to find the job to review the log.
if (i5_command("rtvjoba", array(), array("job" => "job",
"user"=>"user",
"nbr" => "nbr",
"ccsid" => array("ccsid","dec(5 0)"),
"syslibl" => array("syslib","char(165)")))) {
print "Job : $job <br>" ;
print "User : $user <br>" ;
print "Number : $nbr<br>" ;
} else {
echo "Error =".i5_errormsg();
}
print "Connection ID = $conId <br>";

// QCMDEXC should be found on every AS/400
$program = ('*LIBL/QCMDEXC');

$plist = array (
array ( 'name' => 'command', 'io' => I5_IN, 'type' => I5_TYPE_CHAR, 'length' => '50' ),
array ( 'name' => 'length', 'io' => I5_IN, 'type' => I5_TYPE_PACKED, 'length' => '15.5' )
);

$inParms = array ('command' => 'DSPLIB LIB(QGPL) OUTPUT(*PRINT)', 'length' => 50);
$outParms = array ('command' => 'command', 'length' => 'length');

$prepare = i5_program_prepare ( $program, $plist );
i5_program_call ( $prepare, $inParms, $outParms );
print($command);
i5_program_close ( $prepare );

?>

User avatar
shlomov
Zend Global Support
Posts: 139
Joined: Mon Dec 29, 2008 2:38 pm

Re: excessive PHPJOB jobs

Post by shlomov » Wed Aug 26, 2009 2:56 pm

As mentioned the issue will be resolved in the up coming version of the toolkit extensions!
Shlomo Vanunu
IBM System i

timo_karvinen
Posts: 82
Joined: Wed Aug 12, 2009 7:58 am
Location: Tampere, Finland
Contact:

Re: excessive PHPJOB jobs

Post by timo_karvinen » Thu Aug 27, 2009 6:53 am

Exactly what will be resolved? And where has this been mentioned?
Can you post a link to details of upcoming toolkit extension?

Thanks, Timo

Post Reply