Contents |
csa103 Checkpointing
Checkpointing refers to the practice of saving crucial program state in the cluster's "cloud" so that a standby process can resume operation without loss of state upon failure of the active process. This data is saved via the SAFplus Checkpointing APIs into what appears to be a simple key/value in-RAM database (like a hash table). But this "database" is actually replicated by our checkpointing servers and can be shared between multiple components.
Adding checkpointing to your application is simple. You first identify crucial program state and then you have the "active" process write it to a special key/value-database-like subsystem via the Checkpointing APIs. When the "standby" process becomes active, you read the checkpoint and update the program state before resuming service.
Objective
csa103 demonstrates the use of the SAFplus Checkpoint service to provide basic failure recovery. csa103 builds on csa102. The SAFplus Checkpoint service is SA-Forum compliant and this tutorial expects that you will refer to the SA-Forum document for an in-depth description of the checkpointing APIs used.
What Will You Learn
- how to initialize the checkpoint client library,
- how to create a checkpoint and open a checkpoint,
- how to create a section in the checkpoint
- how to save data to the checkpoint section and read data from the checkpoint section.
- how to extend the SAF event dispatch loop to handle multiple services.
The Code
The code can be found within the following directory
<project-area_dir>/eval/src/app/csa103Comp
To increase readability, all checkpointing code has been isolated into a single module that consists of 2 files: checkpointFns.c and checkpointFns.h. These files provide the following APIs.
checkpointFns.h |
---|
|
These APIs constitute the basic operations of any messaging library; initialize, open, send and receive.
This file also declares some checkpoint handles as global variables and defines a "well-known" name for our checkpoint table. This simple example will only have a single row/key in the table (called a "section" in SA-Forum terminology), so we also define a well-known name for the row.
checkpointFns.h |
---|
|
Initialization
Initialization follows the standard SA-Forum library lifecycle pattern where before use an initialize call must occur that returns a handle that is used in subsequent library accesses.
In this example, we will both initialize the library and open the checkpoint table in the same function.
The following code excerpts handle the library initialization:
checkpointFns.c |
---|
|
In this example, we register callbacks that are called when the asynchronous versions of the open and synchronize APIs are called. For threaded applications, it is simpler to use the default, synchronous APIs. The asynchronous versions are used in this example solely for expositional purposes.
Now let's focus on the portions that open the checkpoint table:
checkpointFns.c |
---|
|
A checkpoint creation attributes structure is first defined and then its fields are set to define the behavior of the checkpoint. The definitions of these fields is beyond the scope of this guide, but are available in the SA-Forum checkpointing documentation.
Next, the saCkptCheckpointOpen function is called to open or create the checkpoint table. As the processes that constitute a redundant application start, their initialization routines are racing each other to create/open the table first. Therefore it is necessary to specify the SA_CKPT_CHECKPOINT_CREATE (in all processes) to ensure that whichever process wins will create the checkpoint.
Writing
Writing to a checkpoint section can fail if the section does not exist or if the process is not the checkpoint's "active replica". The active replica is essentially the checkpoint table's "master" copy and is only needed for checkpoints that are configured to allow only one writer. The active replica is assigned via a simple API call that is wrapped here:
checkpointFns.c |
---|
|
The application will call this API when the AMF tells it to become "active" for the CSI (work assignment), as shown in the "Putting it all Together" section.
The following code wraps the section write API. It first attempts to write the section and if that fails, the code creates the section.
checkpointFns.c |
---|
|
The code also synchronizes the checkpoint. This synchronize operation ensures that all replicas have up-to-date data, and is only necessary for certain checkpoint configurations. In this case, the code demonstrates both the synchronous and asynchronous APIs. The async API is currently enabled simply do demonstrate the proper function of the combined AMF and checkpoint event dispatch loop (see the "Putting it all Together" section).
Reading
Reading the checkpoint is quite simple. The API allows for reads of multiple sections and allows subsets of the section's data to be read so an "IO-vector" style data structure is first initialized. To do multiple-section reads, this data structure should be an array of SaCkptIOVectorElementT. But in this example we only read a single section so an array is not needed.
checkpointFns.c |
---|
|
It is important to handle the case of a missing section properly. Whether your application sees this error depends on the design of the application, but is a common design to see missing sections on application start because no prior "active" existed to fill the checkpoint. In this design, it is only on failover that the sections will have been written.
Putting it all Together
These functions are called from the application's clCompAppMain.c file to implement an application that simply prints a sequence count. But this count is checkpointed so it is not affected by process failure!
First, let's define what the program will do when it becomes active. The first step is to take over the "active replica" of the checkpoint so that the process can write the checkpoint. Next, it attempts to read the checkpoint to recover the last sequence number checkpointed by any prior "active" process. Finally, it enters the "active" loop and repeatedly increments the sequence number and writes the checkpoint.
clCompAppMain.c |
---|
|
Next, we move to the "main" function. In the initialization portion we will also initialize the checkpoint:
clCompAppMain.c |
---|
|
Next, we enter the dispatch loop. The auto-generated code creates a loop that handles the AMF processing. This generated loop has been extended to also handle checkpoint processing. Note that it is also perfectly acceptable (even easier) to spawn 2 threads and have one handle the AMF dispatches and the other checkpoint dispatches. This code has been implemented in this manner to show how it can all be done in a single thread.
clCompAppMain.c |
---|
|
Finally, when this application becomes active, we need to kick off the csa103CkptActive function in a new thread:
clCompAppMain.c |
---|
|
In this example, there is nothing to do while the process is assigned standby. This actually can be a problem; if the checkpoint is large it may take quite some time for the newly-assigned active process to completely read and process the checkpoint. The standby can read the checkpoint but how can it determine what it needs to read; what sections the active has changed?
Thus the SA-Forum checkpoint definition is not a "cold standby" because the process is running, but it is also not quite "hot"; we call it a "warm-standby".
But the OpenClovis SAFplus Platform provides an extension to the SA-Forum checkpoint definition that realizes true hot standby behavior. This extension will call an application registered call-back function whenever the active writes the checkpoint with all the write information. This allows the standby to remain in sync with the active so the checkpoint does not need to be read upon failover.
How to Run csa103 and What to Observe
This sample application can run on all Runtime Hardware Setups. The following, lists which node csa103compI*
runs on.
- Runtime Hardware Setup 1.1 and 2.1
csa103compI0 and csa103compI1 will run upon the single node. - Runtime Hardware Setup 1.2 and 2.2
csa103compI0 runs on PayloadNodeI0 and csa103compI1 runs on PayloadNodeI1 - Runtime Hardware Setup 1.3 and 2.3
csa103compI2 and csa103compI3 run on SCNodeI0 and SCNodeI1 respectively. csa103compI0 and csa103compI1 run on PayloadNodeI0 and PayloadNodeI1 respectively.
In the four node set up SCNodeI0 and SCNodeI1 output data via/root/asp/var/log/csa103CompI2
and/root/asp/var/log/csa103CompI3
respectively. Therefore in this case follow the below instructions replacing csa103CompI0 and csa103compI1 with csa103compI2 and csa103compI3 respectively.
We run csa103 very much the same way we run any of the rest of the sample applications: with the SAFplus Platform Console.
- First, on the active System Controller move it to state LockAssignment with (Unlock csa203SGI0 instead of csa103SGI0 to run csa203)
cli[Test]-> setc 1 cli[Test:SCNodeI0]-> setc cpm cli[Test:SCNodeI0:CPM]-> amsLockAssignment sg csa103SGI0
The following output is given when you run
tail -f
on the csa103 log files. For example:# tail -f /root/asp/var/log/csa103CompI0.log
/root/asp/var/log/csa103CompI0Log.latest Mon Jul 14 00:01:09 2008 (SCNodeI0.15238 : csa103CompEO.---.---.00030 : INFO) Component [csa103CompI0] : PID [15238]. Initializing Mon Jul 14 00:01:09 2008 (SCNodeI0.15238 : csa103CompEO.---.---.00031 : INFO) IOC Address : 0x1 Mon Jul 14 00:01:09 2008 (SCNodeI0.15238 : csa103CompEO.---.---.00032 : INFO) IOC Port : 0x81 Mon Jul 14 00:01:09 2008 (SCNodeI0.15238 : csa103CompEO.---.---.00033 : INFO) csa103: Instantiated as component instance csa103CompI0. Mon Jul 14 00:01:09 2008 (SCNodeI0.15238 : csa103CompEO.---.---.00034 : INFO) csa103CompI0: Waiting for CSI assignment... Mon Jul 14 00:01:09 2008 (SCNodeI0.15238 : csa103CompEO.---.---.00035 : INFO) csa103CompI0: Waiting for CSI assignment... Mon Jul 14 00:01:09 2008 (SCNodeI0.15238 : csa103CompEO.---.---.00036 : INFO) csa103CompI0: checkpoint_initialize Mon Jul 14 00:01:10 2008 (SCNodeI0.15238 : csa103CompEO.---.---.00043 : INFO) csa103CompI0: Checkpoint service initialized (handle=0x1) Mon Jul 14 00:01:10 2008 (SCNodeI0.15238 : csa103CompEO.---.---.00045 : INFO) csa103CompI0: Checkpoint opened (handle=0x2)
# tail -f /root/asp/var/log/csa103CompI1.log
/root/asp/var/log/csa103CompI1Log.latest Mon Jul 14 00:01:09 2008 (SCNodeI0.15234 : csa103CompEO.---.---.00030 : INFO) Component [csa103CompI1] : PID [15234]. Initializing Mon Jul 14 00:01:09 2008 (SCNodeI0.15234 : csa103CompEO.---.---.00031 : INFO) IOC Address : 0x1 Mon Jul 14 00:01:09 2008 (SCNodeI0.15234 : csa103CompEO.---.---.00032 : INFO) IOC Port : 0x80 Mon Jul 14 00:01:09 2008 (SCNodeI0.15234 : csa103CompEO.---.---.00033 : INFO) csa103: Instantiated as component instance csa103CompI1. Mon Jul 14 00:01:09 2008 (SCNodeI0.15234 : csa103CompEO.---.---.00034 : INFO) csa103CompI1: Waiting for CSI assignment... Mon Jul 14 00:01:09 2008 (SCNodeI0.15234 : csa103CompEO.---.---.00035 : INFO) csa103CompI1: Waiting for CSI assignment... Mon Jul 14 00:01:09 2008 (SCNodeI0.15234 : csa103CompEO.---.---.00036 : INFO) csa103CompI1: checkpoint_initialize Mon Jul 14 00:01:09 2008 (SCNodeI0.15234 : csa103CompEO.---.---.00043 : INFO) csa103CompI1: Checkpoint service initialized (handle=0x1) Mon Jul 14 00:01:09 2008 (SCNodeI0.15234 : csa103CompEO.---.---.00045 : INFO) csa103CompI1: Checkpoint opened (handle=0x2) Mon Jul 14 00:01:09 2008 (SCNodeI0.15234 : csa103CompEO.---.---.00053 : INFO) csa103CompI1: Section created
- Then, unlock the application by running
cli[Test:SCNodeI0:CPM]-> amsUnlock sg csa103SGI0
In the application log files, you should see
/root/asp/var/log/csa103CompI0Log.latest Mon Jul 14 00:09:08 2008 (SCNodeI0.15238 : csa103CompEO.---.---.00058 : INFO) Standby state requested from state 0
/root/asp/var/log/csa103CompI1Log.latest Mon Jul 14 00:09:08 2008 (SCNodeI0.15234 : csa103CompEO.---.---.00064 : INFO) csa103CompI1: Active state requested from state 0 Mon Jul 14 00:09:09 2008 (SCNodeI0.15234 : csa103CompEO.---.---.00065 : INFO) csa103CompI1: Hello World! (seq=0) Mon Jul 14 00:09:10 2008 (SCNodeI0.15234 : csa103CompEO.---.---.00066 : INFO) csa103CompI1: Hello World! (seq=1) Mon Jul 14 00:09:11 2008 (SCNodeI0.15234 : csa103CompEO.---.---.00067 : INFO) csa103CompI1: Hello World! (seq=2) Mon Jul 14 00:09:12 2008 (SCNodeI0.15234 : csa103CompEO.---.---.00068 : INFO) csa103CompI1: Hello World! (seq=3) Mon Jul 14 00:09:13 2008 (SCNodeI0.15234 : csa103CompEO.---.---.00069 : INFO) csa103CompI1: Hello World! (seq=4)
- Next, find the active csa103 process, the one that's printing the Hello World lines and kill it. To find the process ID issue the following command from a bash shell.
# ps -eaf | grep csa103
This should produce an output that looks similar to the following.
root 17830 15663 0 14:21 ? 00:00:00 csa103Comp -p root 17839 15663 0 14:21 ? 00:00:00 csa103Comp -p root 18558 16145 0 14:32 pts/4 00:00:00 grep csa103
Notice the two entries that end with csa103Comp -p. These are our two component processes. The first one is usually the active process. This is the one that we will kill. In this case the process ID is 17830. So to kill the active component you issue the command:
# kill -9 17830
If this step does not result in the active component being killed then it is likely that the standby component was killed. In this case simply try killing the other process.
After killing the active component you should see lines in the log files like the following:
/root/asp/var/log/csa103CompI1Log.latest Mon Jul 14 00:16:43 2008 (SCNodeI0.15234 : csa103CompEO.---.---.00515 : INFO) csa103CompI1: Hello World! (seq=452) Mon Jul 14 00:16:44 2008 (SCNodeI0.15234 : csa103CompEO.---.---.00516 : INFO) csa103CompI1: Hello World! (seq=453) Mon Jul 14 00:16:45 2008 (SCNodeI0.15234 : csa103CompEO.---.---.00517 : INFO) csa103CompI1: Hello World! (seq=454) Mon Jul 14 00:16:46 2008 (SCNodeI0.15234 : csa103CompEO.---.---.00518 : INFO) csa103CompI1: Hello World! (seq=455)
/var/log/csa103CompI0Log.latest Mon Jul 14 00:16:48 2008 (SCNodeI0.15238 : csa103CompEO.---.---.00065 : INFO) csa103CompI0: Active state requested from state 2 Mon Jul 14 00:16:48 2008 (SCNodeI0.15238 : csa103CompEO.---.---.00066 : INFO) csa103CompI0 reading checkpoint Mon Jul 14 00:16:48 2008 (SCNodeI0.15238 : csa103CompEO.---.---.00067 : INFO) csa103CompI0 read checkpoint: seq = 456 Mon Jul 14 00:16:49 2008 (SCNodeI0.15238 : csa103CompEO.---.---.00068 : INFO) csa103CompI0: Hello World! (seq=456) Mon Jul 14 00:16:50 2008 (SCNodeI0.15238 : csa103CompEO.---.---.00069 : INFO) csa103CompI0: Hello World! (seq=457) Mon Jul 14 00:16:51 2008 (SCNodeI0.15238 : csa103CompEO.---.---.00070 : INFO) csa103CompI0: Hello World! (seq=458)
Where we can see CompI1 printing 455 and then dieing, where upon CompI0 gets the notice to take over processing, reads the checkpoint and then takes over with seq=456 and so on.
Then, in the CompI1 log file we see:
/root/asp/var/log/csa103CompI1Log.latest Mon Jul 14 00:16:49 2008 (SCNodeI0.15553 : csa103CompEO.---.---.00044 : INFO) csa103: Instantiated as component instance csa103CompI1. Mon Jul 14 00:16:49 2008 (SCNodeI0.15553 : csa103CompEO.---.---.00045 : INFO) csa103CompI1: Waiting for CSI assignment... Mon Jul 14 00:16:49 2008 (SCNodeI0.15553 : csa103CompEO.---.---.00046 : INFO) csa103CompI1: Waiting for CSI assignment... Mon Jul 14 00:16:49 2008 (SCNodeI0.15553 : csa103CompEO.---.---.00047 : INFO) csa103CompI1: checkpoint_initialize Mon Jul 14 00:16:50 2008 (SCNodeI0.15553 : csa103CompEO.---.---.00054 : INFO) csa103CompI1: Checkpoint service initialized (handle=0x1) Mon Jul 14 00:16:50 2008 (SCNodeI0.15553 : csa103CompEO.---.---.00056 : INFO) csa103CompI1: Checkpoint opened (handle=0x2)
That is the component that had been killed being restarted.
CompI0 is moving along just fine, and we see CompI1 come back up. If we then kill CompI0 we see:
/root/asp/var/log/csa103CompI1Log.latest Mon Jul 14 00:29:44 2008 (SCNodeI0.15553 : csa103CompEO.---.---.00065 : INFO) csa103CompI1: Active state requested from state 2 Mon Jul 14 00:29:44 2008 (SCNodeI0.15553 : csa103CompEO.---.---.00066 : INFO) csa103CompI1 reading checkpoint Mon Jul 14 00:29:44 2008 (SCNodeI0.15553 : csa103CompEO.---.---.00067 : INFO) csa103CompI1 read checkpoint: seq = 1225 Mon Jul 14 00:29:45 2008 (SCNodeI0.15553 : csa103CompEO.---.---.00068 : INFO) csa103CompI1: Hello World! (seq=1225) Mon Jul 14 00:29:46 2008 (SCNodeI0.15553 : csa103CompEO.---.---.00069 : INFO) csa103CompI1: Hello World! (seq=1226)
Where we can see the CompI0 process die, and CompI1 process read the sequence number from the checkpoint and then take over from where CompI0 left off.
- To stop csa103 use the following SAFplus Platform Console command.
cli[Test:SCNodeI0:CPM]-> amsLockAssignment sg csa103SGI0
- Now change the state of csa103SGI0 to LockInstantiation and close the SAFplus Platform Console.
cli[Test:SCNodeI0:CPM]-> amsLockInstantiation sg csa103SGI0 cli[Test:SCNodeI0:CPM] -> end cli[Test:SCNodeI0] -> end cli[Test] -> bye
csa203
csa203 demonstrates the usage of SA Forum's Checkpointing service. This sample application does not deviate functionally from csa103. The code differences are due to using SA Forum data types (structures) and APIs , as presented in the following two tables. (Note we have not repeated data types and APIs covered previously.)
SA Forum Data Types | OpenClovis Data Types |
---|---|
SaCkptHandleT | ClCkptSvcHdlT |
SaCkptHandleT | ClCkptHdlT |
SaCkptSectionIdT | ClCkptSectionIdT |
SaCkptCheckpointCreationAttributesT | ClCkptCheckpointCreationAttributesT |
SaCkptSectionCreationAttributesT | ClCkptSectionCreationAttributesT |
SaCkptIOVectorElementT | ClCkptIOVectorElementT |
SA Forum APIs | OpenClovis APIs |
---|---|
saCkptInitialize | clCkptInitialize |
saCkptCheckpointOpen | clCkptCheckpointOpen |
saCkptSectionCreate | clCkptSectionCreate |
saCkptCheckpointClose | clCkptCheckpointClose |
saCkptFinalize | clCkptFinalize |
saCkptSectionOverwrite | clCkptSectionOverwrite |
saCkptCheckpointSynchronize | clCkptCheckpointSynchronize |
saCkptCheckpointRead | clCkptCheckpointRead |
How to Run csa103 and What to Observe
This sample application can run on all Runtime Hardware Setups. The following, lists which node csa103compI*
runs on.
- Runtime Hardware Setup 1.1 and 2.1
csa103compI0 and csa103compI1 will run upon the single node. - Runtime Hardware Setup 1.2 and 2.2
csa103compI0 runs on PayloadNodeI0 and csa103compI1 runs on PayloadNodeI1 - Runtime Hardware Setup 1.3 and 2.3
csa103compI2 and csa103compI3 run on SCNodeI0 and SCNodeI1 respectively. csa103compI0 and csa103compI1 run on PayloadNodeI0 and PayloadNodeI1 respectively.
In the four node set up SCNodeI0 and SCNodeI1 output data via/root/asp/var/log/csa103CompI2
and/root/asp/var/log/csa103CompI3
respectively. Therefore in this case follow the below instructions replacing csa103CompI0 and csa103compI1 with csa103compI2 and csa103compI3 respectively.
We run csa103 very much the same way we run any of the rest of the sample applications: with the SAFplus Platform Console.
- First, on the active System Controller move it to state LockAssignment with (Unlock csa203SGI0 instead of csa103SGI0 to run csa203)
cli[Test]-> setc 1 cli[Test:SCNodeI0]-> setc cpm cli[Test:SCNodeI0:CPM]-> amsLockAssignment sg csa103SGI0
The following output is given when you run
tail -f
on the csa103 log files. For example:# tail -f /root/asp/var/log/csa103CompI0.log
/root/asp/var/log/csa103CompI0Log.latest Mon Jul 14 00:01:09 2008 (SCNodeI0.15238 : csa103CompEO.---.---.00030 : INFO) Component [csa103CompI0] : PID [15238]. Initializing Mon Jul 14 00:01:09 2008 (SCNodeI0.15238 : csa103CompEO.---.---.00031 : INFO) IOC Address : 0x1 Mon Jul 14 00:01:09 2008 (SCNodeI0.15238 : csa103CompEO.---.---.00032 : INFO) IOC Port : 0x81 Mon Jul 14 00:01:09 2008 (SCNodeI0.15238 : csa103CompEO.---.---.00033 : INFO) csa103: Instantiated as component instance csa103CompI0. Mon Jul 14 00:01:09 2008 (SCNodeI0.15238 : csa103CompEO.---.---.00034 : INFO) csa103CompI0: Waiting for CSI assignment... Mon Jul 14 00:01:09 2008 (SCNodeI0.15238 : csa103CompEO.---.---.00035 : INFO) csa103CompI0: Waiting for CSI assignment... Mon Jul 14 00:01:09 2008 (SCNodeI0.15238 : csa103CompEO.---.---.00036 : INFO) csa103CompI0: checkpoint_initialize Mon Jul 14 00:01:10 2008 (SCNodeI0.15238 : csa103CompEO.---.---.00043 : INFO) csa103CompI0: Checkpoint service initialized (handle=0x1) Mon Jul 14 00:01:10 2008 (SCNodeI0.15238 : csa103CompEO.---.---.00045 : INFO) csa103CompI0: Checkpoint opened (handle=0x2)
# tail -f /root/asp/var/log/csa103CompI1.log
/root/asp/var/log/csa103CompI1Log.latest Mon Jul 14 00:01:09 2008 (SCNodeI0.15234 : csa103CompEO.---.---.00030 : INFO) Component [csa103CompI1] : PID [15234]. Initializing Mon Jul 14 00:01:09 2008 (SCNodeI0.15234 : csa103CompEO.---.---.00031 : INFO) IOC Address : 0x1 Mon Jul 14 00:01:09 2008 (SCNodeI0.15234 : csa103CompEO.---.---.00032 : INFO) IOC Port : 0x80 Mon Jul 14 00:01:09 2008 (SCNodeI0.15234 : csa103CompEO.---.---.00033 : INFO) csa103: Instantiated as component instance csa103CompI1. Mon Jul 14 00:01:09 2008 (SCNodeI0.15234 : csa103CompEO.---.---.00034 : INFO) csa103CompI1: Waiting for CSI assignment... Mon Jul 14 00:01:09 2008 (SCNodeI0.15234 : csa103CompEO.---.---.00035 : INFO) csa103CompI1: Waiting for CSI assignment... Mon Jul 14 00:01:09 2008 (SCNodeI0.15234 : csa103CompEO.---.---.00036 : INFO) csa103CompI1: checkpoint_initialize Mon Jul 14 00:01:09 2008 (SCNodeI0.15234 : csa103CompEO.---.---.00043 : INFO) csa103CompI1: Checkpoint service initialized (handle=0x1) Mon Jul 14 00:01:09 2008 (SCNodeI0.15234 : csa103CompEO.---.---.00045 : INFO) csa103CompI1: Checkpoint opened (handle=0x2) Mon Jul 14 00:01:09 2008 (SCNodeI0.15234 : csa103CompEO.---.---.00053 : INFO) csa103CompI1: Section created
- Then, unlock the application by running
cli[Test:SCNodeI0:CPM]-> amsUnlock sg csa103SGI0
In the application log files, you should see
/root/asp/var/log/csa103CompI0Log.latest Mon Jul 14 00:09:08 2008 (SCNodeI0.15238 : csa103CompEO.---.---.00058 : INFO) Standby state requested from state 0
/root/asp/var/log/csa103CompI1Log.latest Mon Jul 14 00:09:08 2008 (SCNodeI0.15234 : csa103CompEO.---.---.00064 : INFO) csa103CompI1: Active state requested from state 0 Mon Jul 14 00:09:09 2008 (SCNodeI0.15234 : csa103CompEO.---.---.00065 : INFO) csa103CompI1: Hello World! (seq=0) Mon Jul 14 00:09:10 2008 (SCNodeI0.15234 : csa103CompEO.---.---.00066 : INFO) csa103CompI1: Hello World! (seq=1) Mon Jul 14 00:09:11 2008 (SCNodeI0.15234 : csa103CompEO.---.---.00067 : INFO) csa103CompI1: Hello World! (seq=2) Mon Jul 14 00:09:12 2008 (SCNodeI0.15234 : csa103CompEO.---.---.00068 : INFO) csa103CompI1: Hello World! (seq=3) Mon Jul 14 00:09:13 2008 (SCNodeI0.15234 : csa103CompEO.---.---.00069 : INFO) csa103CompI1: Hello World! (seq=4)
- Next, find the active csa103 process, the one that's printing the Hello World lines and kill it. To find the process ID issue the following command from a bash shell.
# ps -eaf | grep csa103
This should produce an output that looks similar to the following.
root 17830 15663 0 14:21 ? 00:00:00 csa103Comp -p root 17839 15663 0 14:21 ? 00:00:00 csa103Comp -p root 18558 16145 0 14:32 pts/4 00:00:00 grep csa103
Notice the two entries that end with csa103Comp -p. These are our two component processes. The first one is usually the active process. This is the one that we will kill. In this case the process ID is 17830. So to kill the active component you issue the command:
# kill -9 17830
If this step does not result in the active component being killed then it is likely that the standby component was killed. In this case simply try killing the other process.
After killing the active component you should see lines in the log files like the following:
/root/asp/var/log/csa103CompI1Log.latest Mon Jul 14 00:16:43 2008 (SCNodeI0.15234 : csa103CompEO.---.---.00515 : INFO) csa103CompI1: Hello World! (seq=452) Mon Jul 14 00:16:44 2008 (SCNodeI0.15234 : csa103CompEO.---.---.00516 : INFO) csa103CompI1: Hello World! (seq=453) Mon Jul 14 00:16:45 2008 (SCNodeI0.15234 : csa103CompEO.---.---.00517 : INFO) csa103CompI1: Hello World! (seq=454) Mon Jul 14 00:16:46 2008 (SCNodeI0.15234 : csa103CompEO.---.---.00518 : INFO) csa103CompI1: Hello World! (seq=455)
/var/log/csa103CompI0Log.latest Mon Jul 14 00:16:48 2008 (SCNodeI0.15238 : csa103CompEO.---.---.00065 : INFO) csa103CompI0: Active state requested from state 2 Mon Jul 14 00:16:48 2008 (SCNodeI0.15238 : csa103CompEO.---.---.00066 : INFO) csa103CompI0 reading checkpoint Mon Jul 14 00:16:48 2008 (SCNodeI0.15238 : csa103CompEO.---.---.00067 : INFO) csa103CompI0 read checkpoint: seq = 456 Mon Jul 14 00:16:49 2008 (SCNodeI0.15238 : csa103CompEO.---.---.00068 : INFO) csa103CompI0: Hello World! (seq=456) Mon Jul 14 00:16:50 2008 (SCNodeI0.15238 : csa103CompEO.---.---.00069 : INFO) csa103CompI0: Hello World! (seq=457) Mon Jul 14 00:16:51 2008 (SCNodeI0.15238 : csa103CompEO.---.---.00070 : INFO) csa103CompI0: Hello World! (seq=458)
Where we can see CompI1 printing 455 and then dieing, where upon CompI0 gets the notice to take over processing, reads the checkpoint and then takes over with seq=456 and so on.
Then, in the CompI1 log file we see:
/root/asp/var/log/csa103CompI1Log.latest Mon Jul 14 00:16:49 2008 (SCNodeI0.15553 : csa103CompEO.---.---.00044 : INFO) csa103: Instantiated as component instance csa103CompI1. Mon Jul 14 00:16:49 2008 (SCNodeI0.15553 : csa103CompEO.---.---.00045 : INFO) csa103CompI1: Waiting for CSI assignment... Mon Jul 14 00:16:49 2008 (SCNodeI0.15553 : csa103CompEO.---.---.00046 : INFO) csa103CompI1: Waiting for CSI assignment... Mon Jul 14 00:16:49 2008 (SCNodeI0.15553 : csa103CompEO.---.---.00047 : INFO) csa103CompI1: checkpoint_initialize Mon Jul 14 00:16:50 2008 (SCNodeI0.15553 : csa103CompEO.---.---.00054 : INFO) csa103CompI1: Checkpoint service initialized (handle=0x1) Mon Jul 14 00:16:50 2008 (SCNodeI0.15553 : csa103CompEO.---.---.00056 : INFO) csa103CompI1: Checkpoint opened (handle=0x2)
That is the component that had been killed being restarted.
CompI0 is moving along just fine, and we see CompI1 come back up. If we then kill CompI0 we see:
/root/asp/var/log/csa103CompI1Log.latest Mon Jul 14 00:29:44 2008 (SCNodeI0.15553 : csa103CompEO.---.---.00065 : INFO) csa103CompI1: Active state requested from state 2 Mon Jul 14 00:29:44 2008 (SCNodeI0.15553 : csa103CompEO.---.---.00066 : INFO) csa103CompI1 reading checkpoint Mon Jul 14 00:29:44 2008 (SCNodeI0.15553 : csa103CompEO.---.---.00067 : INFO) csa103CompI1 read checkpoint: seq = 1225 Mon Jul 14 00:29:45 2008 (SCNodeI0.15553 : csa103CompEO.---.---.00068 : INFO) csa103CompI1: Hello World! (seq=1225) Mon Jul 14 00:29:46 2008 (SCNodeI0.15553 : csa103CompEO.---.---.00069 : INFO) csa103CompI1: Hello World! (seq=1226)
Where we can see the CompI0 process die, and CompI1 process read the sequence number from the checkpoint and then take over from where CompI0 left off.
- To stop csa103 use the following SAFplus Platform Console command.
cli[Test:SCNodeI0:CPM]-> amsLockAssignment sg csa103SGI0
- Now change the state of csa103SGI0 to LockInstantiation and close the SAFplus Platform Console.
cli[Test:SCNodeI0:CPM]-> amsLockInstantiation sg csa103SGI0 cli[Test:SCNodeI0:CPM] -> end cli[Test:SCNodeI0] -> end cli[Test] -> bye
Additional Tests for Runtime Hardware Setup 1.3 and 2.3
Now repeat the experiment till the stage before we kill the active process and follow these steps.
Step A
- Stop SAFplus Platform on SCNodeI0 using
/etc/init.d/asp stop
. Observer the logs/root/asp/var/log/csa103CompI3Log.latest
on SCNodeI1. This will become active and start printing the hello world logs as above. Note in this case active System Controller SCNode1 is still aware of PayloadNodeI0 and PayloadNodeI1. - Start looking at the logs for
/root/asp/var/log/csa103CompI0Log.latest
in PayloadNodeI0. This will print the standby logs as above. - Stop SAFplus Platform on PayloadNodeI0 and start observing the logs on PayloadNodeI1 in
/root/asp/var/log/csa103CompI1Log.latest
for standby. In this case, you can see, via the active System Controller logs that PayloadNodeI0 is not active whilst PayloadNodeI1 is.
Step B For Hardware Setup 1.3 only
- Repeat A with the slight exception that the blade running SCNodeI0 is yanked out(
/etc/init.d/asp zap
) instead of gracefully shutting down SAFplus Platform in step 1.
Summary and References
We've seen :
- how to use Clovis' checkpoint service to save some program state and recover that state from a separate process
- how to initialize the client checkpoint library
- how to create and open checkpoints
- how to create and use sections in an opened checkpoint
Further information can be found within the following: OpenClovis API Reference Guide.