Toolkit connection problems after migration

General discussion on Zend Server for IBM System i
Post Reply
longnoz
Posts: 39
Joined: Thu Feb 16, 2012 8:55 pm

Toolkit connection problems after migration

Post by longnoz » Sun Dec 15, 2019 3:33 pm

Hello

We just migrated from V7R2 to V7R4, and zend from php 5.? to PHP/7.3.2. We use the toolkit (without CW) extensively for calling RPG programs from PHP. There has been a behavioral change in the toolkit calls since we migrated. There are cases where the primary PHP/SQL returns a list of a thousand products. For each result, we call an RPG program via toolkit to get an extra piece of data. So there are a thousand individual toolkit calls.

The process runs fine on the old server, but takes forever (and never returns a complete data set to the browser) on the new machine. My suspicion is that each toolkit call is opening and closing a db2 connection on the new machine, but I don't know why.The toolkit log has one of these for each table row:
Creating new conn with database: 'Resource id #4', user or i5 naming flag: '', transport: 'ibm_db2', persistence: ''
Re-using existing db connection with schema separator: .

I do not see the same thing on the old server

The code is below:

<?php
function call_ASC707($prg2,$prs,$db) {

include_once("ToolkitService.php");

## use db connection passed in from calling program
try { $obj = ToolkitService::getInstance($db); }
catch (Exception $e) {
echo $e->getMessage(), "ddd\n"; exit();
}

$PmPrs1 = "";
$PmPrs2 = "";
$PmPrs3 = "";
$PmErr = "";

$obj->setToolkitServiceParams(array('stateless'=>"true", 'debug'=>false, 'plug'=>"iPLUG32K"));

$cmd = "ADDLIBLE ".strtoupper($qs36f);
$cmd1 = $obj->CLCommand($cmd);

$param = [];
$param[] = $obj->AddParameterChar('in', 2,'PmPrg2', 'PmPrg2', $prg2);
$param[] = $obj->AddParameterChar('in', 2,'PmPrs#', 'PmPrs#', $prs);
$param[] = $obj->AddParameterChar('out', 5,'PmPrs1', 'PmPrs1', $PmPrs1);
$param[] = $obj->AddParameterChar('out', 5,'PmPrs2', 'PmPrs2', $PmPrs2);
$param[] = $obj->AddParameterChar('out', 5,'PmPrs3', 'PmPrs3', $PmPrs3);
$param[] = $obj->AddParameterChar('out', 3,'PmErr', 'PmErr', $PmErr);

$result = $obj->PgmCall("ASC707", strtoupper($alllib), $param, null, null);

if($result) {
$outputParams = $result['io_param'];
$SPEC1 = $outputParams['PmPrs1'];
$SPEC2 = $outputParams['PmPrs2'];
$SPEC3 = $outputParams['PmPrs3'];
$ERRCD = $outputParams['PmErr'];
} else {
echo "Error calling ASC707-> $result<br>";
}

return array($SPEC1,$SPEC2,$SPEC3);

}

?>

jonfparis
Posts: 24
Joined: Thu Apr 09, 2009 9:51 pm

Re: Toolkit connection problems after migration

Post by jonfparis » Tue Dec 31, 2019 6:51 pm

Did you have any luck worth resolving this issue? I seem to be having a similar problem since moving to 7.4 - although we are still on PHP 5.6

longnoz
Posts: 39
Joined: Thu Feb 16, 2012 8:55 pm

Re: Toolkit connection problems after migration

Post by longnoz » Wed Jan 08, 2020 7:02 pm

No luck yet

aseiden
Posts: 877
Joined: Thu Apr 09, 2009 5:45 pm

Re: Toolkit connection problems after migration

Post by aseiden » Thu Jan 09, 2020 2:21 am

Hi, Longnoz,

Although I don't see a good reason for the issue you report (because passing the database connection should work), you could optimize your code by moving the toolkit connection, toolkit options, and the addlible to a point before your loop begins. Then pass in the toolkit object to your program call function, rather than repeating the getInstance, etc. (the addlible is redundant after the first time and may be generating error log messages under the covers)..

I'd be interested in hearing your results if you are able to try this.

Alan Seiden
http://seidengroup.com

longnoz
Posts: 39
Joined: Thu Feb 16, 2012 8:55 pm

Re: Toolkit connection problems after migration

Post by longnoz » Sat Jan 11, 2020 12:01 am

Alan

Well if this were to be my permanent solution, I will have quite a few programs to change. But it's do-able.

So I moved the following code:

include_once("ToolkitService.php");

try { $obj = ToolkitService::getInstance($db); }
catch (Exception $e) {
echo $e->getMessage(), "ddd\n"; exit();
}


from the program call function to the primary program. But I get this error message as soon as it tries to create the toolkit connection

Relational database ToolkitService obj not in relational database directory. SQLCODE=-950

Thanks

aseiden
Posts: 877
Joined: Thu Apr 09, 2009 5:45 pm

Re: Toolkit connection problems after migration

Post by aseiden » Wed Jan 15, 2020 1:42 pm

Hi, Longnoz,

Based on a side discussion, here's the status of your issue:
1. Connection is working
2. I suggested you check the toolkit debug log (which I believe you are logging to) for timing details of each step.

Thanks,
Alan
http://www.seidengroup.com

longnoz
Posts: 39
Joined: Thu Feb 16, 2012 8:55 pm

Re: Toolkit connection problems after migration

Post by longnoz » Wed Jan 15, 2020 5:29 pm

Hi

The problem was that for each call to the function, we were doing an ADDLIBLE to add a library to the library list. On the first ADDLIBLE there is no error msg, but on the subsequent calls it returns the message "library already on library list". This is a warning message, the job continues. But is seems that it was taking about 1.25 seconds to process these warning messages. By moving the ADDLIBLE outside the function and into the calling program, it solved the problem

Why it takes 1.25 seconds now, but did not on the old machine, is a mystery.

Thanks for your help Alan

Post Reply