How to apply patch while you are in the middle of ADPATCH

How to apply patch while you are in the middle of ADPATCH
=================================================


1.  Using the adctrl utility, shutdown the workers.
    a. adctrl
    b. Select option 3 "Tell worker to shutdown/quit"
2.  Backup the FND_INSTALL_PROCESSES table which is owned by the APPLSYS schema
    a. sqlplus applsys/<password>
    b. create table fnd_Install_processes_back
       as select * from fnd_Install_processes;
    c. The 2 tables should have the same number of records.
       select count(*) from fnd_Install_processes_back;
       select count(*) from fnd_Install_processes;
3.  Backup the AD_DEFERRED_JOBS table.
    a. sqlplus applsys/<password>
    b. create table AD_DEFERRED_JOBS_back
       as select * from AD_DEFERRED_JOBS;
    c. The 2 tables should have the same number of records.
       select count(*) from AD_DEFERRED_JOBS_back;
       select count(*) from AD_DEFERRED_JOBS;
4.  Backup the .rf9 files located in $APPL_TOP/admin/<SID>/restart directory.
    At this point, the adpatch session should have ended and the cursor should
    be back at the Unix prompt.
    a. cd $APPL_TOP/admin/<SID>
    b. mv restart restart_back
    c. mkdir restart
5.  Drop the FND_INSTALL_PROCESSES table and the AD_DEFERRED_JOBS table.
    a. sqlplus applsys/<password>
    b. drop table FND_INSTALL_PROCESSES;
    c. drop table AD_DEFERRED_JOBS;
6.  Apply the new patch.
7.  Restore the .rf9 files located in $APPL_TOP/admin/<SID>/restart_back
    directory.
    a. cd $APPL_TOP/admin/<SID>
    b. mv restart restart_<patchnumber>
    c. mv restart_back restart
8. Restore the FND_INSTALL_PROCESSES table which is owned by the APPLSYS
    schema.
    a. sqlplus applsys/<password>
    b. create table fnd_Install_processes
       as select * from fnd_Install_processes_back;
    c. The 2 tables should have the same number of records.
       select count(*) from fnd_Install_processes;
       select count(*) from fnd_Install_processes_back;
9. Restore the AD_DEFERRED_JOBS table.
    a. sqlplus applsys/<password>
    b. create table AD_DEFERRED_JOBS
       as select * from AD_DEFERRED_JOBS_back;
    c. The 2 tables should have the same number of records.
       select count(*) from AD_DEFERRED_JOBS_back;
       select count(*) from AD_DEFERRED_JOBS;
10. Re-create synonyms
    a. sqlplus apps/apps
    b. create synonym AD_DEFERRED_JOBS for APPLSYS.AD_DEFERRED_JOBS;
    c. create synonym FND_INSTALL_PROCESSES FOR APPLSYS.FND_INSTALL_PROCESSES;
11. Start adpatch, it will resume where it stopped previously.


How to apply patch while you are in the middle of patching:
=============================================                                              
Summary

Sometimes when you are in the middle of applying a patch you may get adworkers errors or you can find out that a patch is missing.

So you need to apply a second patch (which solves the problem) in the middle of a running patch.

1. Use adctrl (option 3) to tell all the existing workers to QUIT

2. Use adctrl (option 5) to tell managers that all workers have QUIT. (Adpatch session ends!)

3. Backup tables applsys.ad_deferred_jobs and applsys.fnd_install_processes.
Login as APPLSYS user and execute:
ALTER "TABLE" applsys.ad_deferred_jobs "RENAME" TO ad_deferred_jobs_old;
ALTER "TABLE" applsys.fnd_install_processes "RENAME" TO fnd_install_processes_old;
ALTER "INDEX" applsys.ad_deferred_jobs_u1 "RENAME" TO ad_deferred_jobs_u1_old;
ALTER "INDEX" applsys.fnd_install_processes_u1 "RENAME" TO fnd_install_processes_u1_old;
4. Go to $APPL_TOP/admin/SID/ for example $APPL_TOP/admin/TEST/ and rename the existing directory "restart"

$mv restart restart.old

5. Use adpatch to apply the second/other patch.

6. Login as APPLSYS and revert back to the original tables, ad_deferred_jobs and fnd_install_processes
ALTER "TABLE" applsys.ad_deferred_jobs_old "RENAME" TO ad_deferred_jobs;
ALTER "TABLE" applsys.fnd_install_processes_old "RENAME" TO fnd_install_processes;
ALTER "INDEX" applsys.ad_deferred_jobs_u1_old "RENAME" TO ad_deferred_jobs_u1;
ALTER "INDEX" applsys.fnd_install_processes_u1_old "RENAME" TO fnd_install_processes_u1;
CREATE SYNONYM FND_INSTALL_PROCESSES FOR APPLSYS.FND_INSTALL_PROCESSES;
CREATE SYNONYM AD_DEFERRED_JOBS FOR APPLSYS.AD_DEFERRED_JOBS;
7. Replace the original restart directory:

cd $APPL_TOP/admin/SID/ for example $APPL_TOP/admin/TEST/
mv restart restart_new
mv restart.old restart

8. Run adpatch to continue the first patch (with continue session?Yes)

9. Use adctrl (option 2, will change status to “Fixed/Restart”) to restart the failed workers for first patch

What to do if a worker fails during adpatch application on R12:

=====================================================================
In a different window constantly monitor the patch worker using adctrl command.

1. set the application environment file of R12

2. run adctrl

check the status of the worker using option 1 [Show worker status].

If a worker fails. 

1. Check adwork01.log [check the failed worker number] file under $APPL_TOP/admin//log directory for details about the error.

2. Fix the issue mentioned in worker file.

3. Use Option 2 [Tell worker to restart a failed job] to restart the failed job in adctrl window.

4. If the issue is fixed properly the worker will start and complete the job and your adpatch will continue executing.


Sometimes, you need to restart all the workers and exit the adpatch session and restart it from the failed location will do your job.

No comments: