A good way to speed up your PHP application is to have a persistent connection to the IBM i DB2 database. This does, however, carry one implication that might need consideration when modernizing your legacy applications. With persistent connections “shared read” locks, or *SHRRD locks are created on the objects you are accessing. Via Alan Seiden (he created the two methods below) there are two ways to handle these locks to dismiss them. One quick and dirty, the other a bit more elegant.

1. Quick and dirty:

If you just restart the Apache instance, all corresponding QSQSRVR jobs will be reset, clearing the locks.

2. Elegant:

You can add the command below to the evening job stream that later allocates/clears the file. The command will ask any jobs having locks to release those locks. In my experience, this has worked perfectly with QSQSRVR jobs that hold *SHRRD pseudo-locks on the object.

For file MYFILE:


if a member:

Make sure you add a MONMSG immediately after the ALCOBJ command to handle any messages such as “cannot allocate…” which may arise normally.

And there we have it!