6.2 Back Up Cached Maintenance Data

To retain information that's available in the cache, you must run the MicroTx transaction coordinator in maintenance mode before upgrading it.

When you enable cache, the cached data is available only locally to optimize the read and write operations. When you start the maintenance mode, transaction logs for all the replicas of the MicroTx coordinator are populated in both, the data store and cache.

You can back up cached data only when the following conditions are satisfied. Skip this procedure if the following conditions are not satisfied.

  • Caching is enabled for the MicroTx transaction coordinator. See Enable Caching.
  • MicroTx uses Oracle Database or etcd as data store. You cannot enable caching if you use internal memory as the data store.
To run the MicroTx transaction coordinator in maintenance mode:
  1. Based on your environment, update the value of the namespace where you have deployed MicroTx in the maintenance-broadcast.yaml file. The maintenance-broadcast.yaml is in the installation_directory/otmm-RELEASE/otmm/microtx-upgrade/maintenance folder.
  2. Run the maintenance-broadcast.yaml file in the namespace where you have deployed the MicroTx transaction coordinator.
    cd installation_directory/otmm-RELEASE/otmm/microtx-upgrade/maintenance
    kubectl apply -f maintenance-broadcast.yaml

    The following output is displayed.

    serviceaccount/otmm-tcs created
    pod/maintenance-job created
    role.rbac.authorization.k8s.io/endpoint-listing-role created
    rolebinding.rbac.authorization.k8s.io/endpoint-listing-role-binding created
    peerauthentication.security.istio.io/otmm-tcs-peerauth created
  3. Clear the outdated cached maintenance data from the maintenance table in data store. This deletes the data which was backed up when you ran the transaction coordinator in the maintenance mode during an earlier upgrade. The maintenance-script.sh is in the installation_directory/otmm-RELEASE/otmm/microtx-upgrade/maintenance folder.
    kubectl exec -it maintenance-job -n otmm -- /bin/sh -c "$(cat maintenance-script.sh)"

    The following options are displayed.

    Which URL would you like to hit?
    1) Clear old maintenance data
    2) Start maintenance (5 mins)
    3) Start maintenance with a duration (mins)
    4) Check maintenance status
    Enter your choice (1, 2, 3 or 4):
    1. Enter 1.

      Caution:

      You must clear the outdated maintenance data before starting the maintenance mode. Do not use this option after starting the maintenance mode. In case of any data corruption in the maintenance mode or if the pods become unresponsive, this option can serve as a recovery point to restart the process.
    2. Enter the name of the MicroTx application that you have deployed.
    3. Enter the port over which you want to access the MicroTx transaction coordinator.
    Wait for the following message to be displayed, before proceeding to the next step.
    Maintenance data deleted successfully
  4. Run the script again to start the maintenance mode, and then enter option 2 or 3.
    kubectl exec -it maintenance-job -n otmm -- /bin/sh -c "$(cat maintenance-script.sh)"
    • Enter 2 to use the default time buffer of 5 minutes for the ongoing transactions to complete.
    • Enter 3 to use specify a time buffer, in minutes, for the ongoing transactions to complete. You will be prompted to enter a value in minutes. Enter an integer which is more than 5. If you enter a value less than 5 minutes, the script uses the default value of 5 minutes.

    The following message is displayed when the maintenance mode starts.

    coordinator maintenance process started
  5. Run the script again, and then enter option 4 to check the progress and to confirm that the maintenance mode has completed successfully.
    kubectl exec -it maintenance-job -n otmm -- /bin/sh -c "$(cat maintenance-script.sh)"

    The following message is displayed when the maintenance mode is completed successfully.

    maintenance mode completed

    You may need to run this step a few times if the maintenance mode is still is progress. Proceed with the next step only after ensuring that the maintenance mode has completed successfully.

  6. Run the following command to delete the resources created by maintenance-broadcast.yaml.
    kubectl delete -f maintenance-broadcast.yaml

    The following message is displayed.

    serviceaccount "otmm-tcs" deleted
    pod "maintenance-job" deleted
    role.rbac.authorization.k8s.io "endpoint-listing-role" deleted
    rolebinding.rbac.authorization.k8s.io "endpoint-listing-role-binding" deleted
    peerauthentication.security.istio.io "otmm-tcs-peerauth" deleted

Next: Use a suitable method to upgrade to the latest release of Transaction Manager for Microservices Enterprise Edition. When you upgrade to the latest release, the upgrade process shuts down the older replicas of the MicroTx coordinator and the brings up new replicas of the MicroTx coordinator in a rolling fashion. The cache of the new MicroTx coordinator replicas are populated with the copy of the cached maintenance data that's available in the data store.