You are on page 1of 9

Establishing Checkpoints

Objectives
• Define the concept of a checkpoint.
• Restart a job from a checkpoint.

61
Copyri g ht © S A S Insti tute Inc. A l l ri g hts reserved.
2

Checkpoints
By default, if a job is interrupted during execution, it has to be rerun in its
entirety. With checkpoints established, the job can be restarted from the last
checkpoint before the interruption.

62
Copyri g ht © S A S Insti tute Inc. A l l ri g hts reserved.

A checkpoint
• consists of code that manages checkpoint restart information
• preserves checkpoint state information
• replaces the saved state information for any previous checkpoint in the job
• enables the job to be restarted from the checkpoint
• conserves resources by not reprocessing already completed steps.

Job Interruption
When a job is interrupted, the last checkpoint passed is the checkpoint that
is used to preserve the state of the job up to that point.
State of the job is preserved up
to most recent checkpoint

Error!

63
Copyri g ht © S A S Insti tute Inc. A l l ri g hts reserved.
Establishing Checkpoints 3

Restarting a Job
After an interruption, the job can be restarted
• from the beginning
• from the last checkpoint.

When a job is restarted from the last checkpoint,


• steps preceding the checkpoint are skipped
• state is restored from the save-state information.
64
Copyri g ht © S A S Insti tute Inc. A l l ri g hts reserved.

Note: This applies to running jobs interactively. To restart a batch job from checkpoint-restart data,
turn on the STEPRESTART option.

Checkpoint Caveats
A checkpoint does not preserve several items:
• SAS global options
• session compiled macros
• remote connections

If your job contains one or


more of the above items,
it is recommended to put
these items in a
transformation (perhaps a
User Written transformation) and configure the transformation
to always run when restarting.
65
Copyri g ht © S A S Insti tute Inc. A l l ri g hts reserved.

Note: All transformations have an Options tab as part of the transformation properties, and every
transformation has the two checkpoint options, as shown.
4

Adding Checkpoints to a Job


This demonstration illustrates marking selected transformations as restart points in a job.

1. If necessary, access SAS Data Integration Studio using Bruno’s credentials.


a. Select Start  All Programs  SAS  SAS Data Integration Studio.
b. Verify that the connection profile is My Server.
c. Click OK to close the Connection Profile window. The Log On window appears.
d. Enter Bruno as the user ID and Student1 as the password.
e. Click OK to close the Log On window.
2. Open the DIFT Test Job - OrderFact Table Plus job.
a. Click the Folders tab.
b. Expand the Data Mart Development  DIFT Demo folder.
Note: If necessary, the needed job can be imported from the DIFT Demo.spk package in
the D:\Workshop\dift\solutions folder. The DIFT Demo.spk package can also be
downloaded from the ELP Packages folder on the Extended Learning Page.
c. Double-click the DIFT Test Job - OrderFact Table Plus job to open it in the job editor.
3. Add a checkpoint for the Table Loader transformation.
a. Right-click the Table Loader transformation and select Assign as Restart-Point.

b. Click New next to the Restart-point state library field.


The New Library Wizard appears.
1) Click SAS BASE Library as the type of library to define.
2) Click Next.
3) Enter DIFT Restart Point Library as the name.
4) Verify that the location is set to /Data Mart Development/DIFT Demo.
5) Click Next.
6) Double-click SASApp to move it to the Selected servers list.
7) Click Next.
8) Enter diftckpt in the Libref field.
Establishing Checkpoints 5

9) Click New in the Path Specification area.


a) Click Browse in the New Path Specification window.
(1) Navigate to D:\Workshop\dift.
(2) Click to create a new folder.
(3) Type checkpoint and press Enter.
(4) Click the new folder.
(5) Click OK to close the Browse window.
b) Click OK to close the New Path Specification window.
The new path is displayed in the Selected Items list:

10) Click Next.


11) Verify that the information is correct, and then click Finish.
c. Click the ellipsis button in the Alternative library for temporary tables (optional) field.
The Select a Library window appears.
1) On the Folders tab, expand Data Mart Development  DIFT Demo.
2) Select the DIFT Restart Point Library.
3) Click OK.

Note: Different libraries can be specified for Restart point state library and
Alternative library for temporary tables if needed.
d. Click OK to close the Restart-point Setup window.
The Table Loader transformation is decorated with a symbol to indicate that this
transformation is assigned as a restart point.

4. Reassign the work table of the join to the alternative work library.
a. Right-click the Join work table and select Properties.
b. Click the Physical Storage tab.
c. Enter SQLJoin in the Physical name field.
6

d. Clear the Create as view option.


e. Verify that Job’s default library for temporary tables is selected in the Location field.
f. Verify that the Library field has the value DIFT Restart Point Library.

g. Click OK to close the Properties window.


5. Add a checkpoint for the Sort transformation by right-clicking the Sort transformation and
selecting Assign as Restart-Point.

The restart point libraries established earlier apply to all checkpoints in the job. Thus, the
Restart-point Setup window does not appear again.
6. Select File  Save to save the job metadata.
7. Verify that the title bar of the job editor window has been enhanced with a note.

8. Verify that the restart point libraries established earlier are assigned at the job level.
a. Right-click in the background of the job and select Properties.
b. Click the Options tab.
c. Click the Checkpoint options group.
d. Verify that DIFT Restart Point Library is set as the job-level restart-point state library.
Establishing Checkpoints 7

e. Click the Code tab.


f. Locate the code for the checkpoint/restart settings.
The code begins with a macro that assigns the Alternate Temporary Library and is
followed by code to assign the libref for DIFT Restart Point Library.

g. Scroll through the code and notice that each transformation code block is surrounded by
additional code that processes if a job fails.
h. Click OK to close the Properties window.
9. Mimic “failure” of a job by stopping the job during Rank transformation processing.
a. Right-click the Rank transformation and select Properties to open the Properties window.
b. Click the Precode and Postcode tab.
c. Enter the following code in the precode of the Rank transformation:
data _null_;
abort abend;
run;
d. Click OK to close the Properties window.
e. In the job editor window, click Run.
The Details pane shows that the process was stopped.

f. Select File  Close to close the job editor window.


8

10. Access Windows Explorer to investigate the physical contents of the restart point library.
a. Open Windows Explorer.
b. Navigate to D:\Workshop\dift\checkpoint.

Two data sets and a data set view were created. They are used to restart the job at the Table
Loader checkpoint.
11. Restart the job. (You would do this after the “problem” is resolved.)
a. Open the job DIFT Test Job – OrderFact Table Plus.
b. If necessary, remove the precode in the Rank transformation.
c. In the job editor window, click Run.
The Run Options window appears.

d. Click Restart from checkpoint taken immediately before Table Loader.


e. Click OK.
f. Verify that the job has completed successfully.

The restart skipped the Join transformation and completed all the remaining steps.
g. Select File  Close to close the job editor window.
Establishing Checkpoints 9

7.10 Poll
When a job is stopped, the job can be restarted from any checkpoint it has
successfully passed.

 True
 False

68
Copyri g ht © S A S Insti tute Inc. A l l ri g hts reserved.

You might also like