According to the WSO2 patch application process, once the patches are created, you can apply them either as individual patches or through a service pack. However, when the number of patches increase, it is more convenient to apply patches through service packs.
What is a service pack?
Carbon 4.2.0 kernel supports service packs. A service pack is a collection of patches in a single pack. It contains two elements: the lib
directory and the servicepack_patches.txt
text file. The lib
directory contains all the patching JARs relevant to the service pack, and the metadata file contains the list of patches applied by the service pack.
The following sections explains the patch application procedure:
Applying patches to the Kernel
- Copy the required patches and service packs to the relevant locations in your product directory as explained below.
- To apply patches individually, copy the patches to
<PRODUCT_HOME>/repository/components/patches.
To apply a service pack, copy the service pack file to
<PRODUCT_HOME>/repository/components/servicepacks.
For example, the image below shows how a new service pack, named "servicepack001", is added to this directory.
- To apply patches individually, copy the patches to
Start the Carbon server. If any patch changes exist, the following steps will be executed:
- Before applying any patches, the process first creates a backup folder named
patch0000
inside the<PRODUCT_HOME>/repository/components/patches
directory, which will contain the original content of theplugins
folder that is in the<PRODUCT_HOME>/repository/components
directory. This step enables you to revert back to the previous state if something goes wrong during operations. If any service packs are copied to the
servicepacks
directory, the latest service pack will be applied. That is, the patches in the service pack will be applied to the<PRODUCT_HOME>/repository/components/plugins
directory.- After the service pack is applied, any other patches that were not included in the service pack will be incrementally applied to the
plugins
directory. The metadata file available in the service pack will maintain a list of the applied patches by service pack. Therefore, the metadata file information will be compared against the<PRODUCT_HOME>/repository/components/patches
directory, and only the patches that were not applied by the service pack will be incrementally applied to theplugins
directory. The diagram below shows how the patch application is implemented when you start the server.
Prior to the Carbon 4.2.0 release, to apply patches in the Carbon server, the users were expected to start the server as follows:
wso2server.sh -DapplyPatches.
Now, you do not have to issue a special command to trigger the patch process. It starts automatically if there are changes in either the<PRODUCT_HOME>/repository/components/servicepacks
directory or the<PRODUCT_HOME>/repository/components/patches
directory. It verifies all the latest JARs in theservicepacks
andpatches
directories against JARs in theplugins
directory by comparing MD5s of JARs.- Before applying any patches, the process first creates a backup folder named
Verifying the patch application
After the patch application process is completed, the patch verification process ensures that the latest service pack and other existing patches are correctly applied to the <PRODUCT_HOME>/repository/components/plugins
folder.
- All patch related logs are recorded in the
<PRODUCT_HOME>repository/logs/
file.patches.log
- The
<PRODUCT_HOME>/repository/components/patches/.metadata/prePatchedJARs.txt
meta file contains the list of patched JARs and their md5 values. - A list of all the applied service packs and patches are in the
<PRODUCT_HOME>/repository/components/default/configuration/prePatched.txt
file.
Do not change the data in the <PRODUCT_HOME>/repository/components/default/configuration/prePatched.txt
file. The patch application process gets the pre-patched list from this file and compares the list with the patches available in the servicepack
and patches
directories. If you change the data in this file, you will get a startup error when applying patches.