ibm-information-center/dist/eclipse/plugins/i5OS.ic.ddp_5.4.0.1/rbal1rcvtrn.htm

425 lines
22 KiB
HTML
Raw Normal View History

2024-04-02 14:02:31 +00:00
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="security" content="public" />
<meta name="Robots" content="index,follow" />
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<meta name="DC.Type" content="reference" />
<meta name="DC.Title" content="Transaction recovery through commitment control" />
<meta name="abstract" content="Commitment control is an extension of the journal management function on the iSeries server. The server can identify and process a group of relational database changes as a single unit of work (transaction)." />
<meta name="description" content="Commitment control is an extension of the journal management function on the iSeries server. The server can identify and process a group of relational database changes as a single unit of work (transaction)." />
<meta name="DC.subject" content="commitment control, transaction recovery, lock levels, starting, SQL program, starting commitment control, interactive SQL, command, Start Commitment Control (STRCMTCTL), commitment control, notify object (NFYOBJ) parameter, NFYOBJ (notify object) parameter, notify object (NFYOBJ) parameter, LCKLVL parameter, command, STRCMTCTL (Start Commitment Control), Start Commitment Control (STRCMTCTL), command, CL, STRCMTCTL (Start Commitment Control), record lock durations" />
<meta name="keywords" content="commitment control, transaction recovery, lock levels, starting, SQL program, starting commitment control, interactive SQL, command, Start Commitment Control (STRCMTCTL), commitment control, notify object (NFYOBJ) parameter, NFYOBJ (notify object) parameter, notify object (NFYOBJ) parameter, LCKLVL parameter, command, STRCMTCTL (Start Commitment Control), Start Commitment Control (STRCMTCTL), command, CL, STRCMTCTL (Start Commitment Control), record lock durations" />
<meta name="DC.Relation" scheme="URI" content="rbal1recovsupp.htm" />
<meta name="DC.Relation" scheme="URI" content="../db2/rbafzmsth2clcu.htm" />
<meta name="DC.Relation" scheme="URI" content="../cl/strcmtctl.htm" />
<meta name="DC.Relation" scheme="URI" content="../rzakj/rzakjtrouble.htm" />
<meta name="DC.Relation" scheme="URI" content="../cl/wrkcmtdfn.htm" />
<meta name="DC.Relation" scheme="URI" content="rbal1cmt.htm" />
<meta name="DC.Relation" scheme="URI" content="rbal1saverestore.htm" />
<meta name="DC.Relation" scheme="URI" content="../cl/savobj.htm" />
<meta name="DC.Relation" scheme="URI" content="../cl/savlib.htm" />
<meta name="DC.Relation" scheme="URI" content="../cl/savchgobj.htm" />
<meta name="DC.Relation" scheme="URI" content="../cl/savsavfdta.htm" />
<meta name="DC.Relation" scheme="URI" content="../cl/savsys.htm" />
<meta name="DC.Relation" scheme="URI" content="../cl/rstlib.htm" />
<meta name="DC.Relation" scheme="URI" content="../cl/rstobj.htm" />
<meta name="DC.Relation" scheme="URI" content="../cl/rstusrprf.htm" />
<meta name="DC.Relation" scheme="URI" content="../cl/rstaut.htm" />
<meta name="DC.Relation" scheme="URI" content="../cl/rstcfg.htm" />
<meta name="DC.Relation" scheme="URI" content="../cl/savsys.htm" />
<meta name="copyright" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="rbal1rcvtrn" />
<meta name="DC.Language" content="en-us" />
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
<link rel="stylesheet" type="text/css" href="./ic.css" />
<title>Transaction recovery through commitment control</title>
</head>
<body id="rbal1rcvtrn"><a name="rbal1rcvtrn"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Transaction recovery through commitment control</h1>
<div><p>Commitment control is an extension of the journal management function
on the <span class="keyword">iSeries™ server</span>. The server
can identify and process a group of relational database changes as a single
unit of work (transaction).</p>
<div class="section"><p>An SQL COMMIT statement guarantees that the group of operations
is completed. An SQL ROLLBACK statement guarantees that the group of operations
is backed out. The only SQL statements that cannot be committed or rolled
back are: </p>
<ul><li>DROP COLLECTION</li>
<li>GRANT or REVOKE if an authority holder exists for the specified object</li>
</ul>
</div>
<div class="section"><p>Under commitment control, tables and rows used during a transaction
are locked from other jobs. This ensures that other jobs do not use the data
until the transaction is complete. At the end of the transaction, the program
issues an SQL COMMIT or ROLLBACK statement, freeing the rows. If the server
or job ends abnormally before the commit operation is performed, all changes
for that job since the last time a commit or rollback operation occurred are
rolled back. Any affected rows that are still locked are then unlocked. The
lock levels are as follows: </p>
<dl><dt class="dlterm">*NONE</dt>
<dd>Commitment control is not used. Uncommitted changes in other jobs can
be seen.</dd>
<dt class="dlterm">*CHG</dt>
<dd>Objects referred to in SQL ALTER, COMMENT ON, CREATE, DROP, GRANT, LABEL
ON, and REVOKE statements and the rows updated, deleted, and inserted are
locked until the unit of work (transaction) is completed. Uncommitted changes
in other jobs can be seen.</dd>
<dt class="dlterm">*CS</dt>
<dd>Objects referred to in SQL ALTER, COMMENT ON, CREATE, DROP, GRANT, LABEL
ON, and REVOKE statements and the rows updated, deleted, and inserted are
locked until the unit of work (transaction) is completed. A row that is selected,
but not updated, is locked until the next row is selected. Uncommitted changes
in other jobs cannot be seen.</dd>
<dt class="dlterm">*ALL</dt>
<dd>Objects referred to in SQL ALTER, COMMENT ON, CREATE, DROP, GRANT, LABEL
ON, and REVOKE statements and the rows read, updated, deleted, and inserted
are locked until the end of the unit of work (transaction). Uncommitted changes
in other jobs cannot be seen.</dd>
</dl>
</div>
<div class="section"><p><a href="#rbal1rcvtrn__rbal1reclock">Table 1</a> shows the record
lock duration for each of these lock level values.</p>
</div>
<div class="section"><div class="p">If you request COMMIT (*CHG), COMMIT (*CS), or COMMIT (*ALL) when
the program is precompiled or when Interactive SQL is started, then SQL sets
up the commitment control environment by implicitly calling the <span class="cmdname">Start
Commitment Control (STRCMTCTL)</span> command. The LCKLVL parameter specified
when SQL starts commitment control is the lock level specified on the COMMIT
parameter on the CRTSQL<em>xxx</em> commands. NFYOBJ(*NONE) is specified when
SQL starts commitment control. To specify a different NFYOBJ parameter, issue
a (STRCMTCTL) command before starting SQL. <div class="note"><span class="notetitle">Note:</span> When running with commitment
control, the tables referred to in the application program by data manipulation
language statements must be journaled. The tables do not have to be journaled
at precompile time, but they must be journaled when you run the application.</div>
</div>
</div>
<div class="section"><p>If a remote relational database is accessing data on the server
and requesting commit level repeatable read (*RR), the tables will be locked
until the query is closed. If the cursor is read only, the table will be locked
(*SHRNUP). If the cursor is in update mode, the table will be locked (*EXCLRD).</p>
</div>
<div class="section"><p>The journal created in the SQL collection is normally the journal
used for logging all changes to SQL tables. You can, however, use the server
journal functions to journal SQL tables to a different journal.</p>
</div>
<div class="section"><p>Commitment control can handle up to 131 072 distinct row changes
in a unit of work. If COMMIT(*ALL) is specified, all rows read are also included
in the 131 072 limit. (If a row is changed or read more than once in a unit
of work, it is only counted once toward the 131 072 limit.) Maintaining a
large number of locks adversely affects server performance and does not allow
concurrent users to access rows locked in the unit of work until the unit
of work is completed. It is, therefore, more efficient to keep the number
of rows processed in a unit of work small. Commitment control allows up to
512 tables either open under commitment control or closed with pending changes
in a unit of work.</p>
</div>
<div class="section"><p>The HOLD value on COMMIT and ROLLBACK statements allows you to
keep the cursor open and start another unit of work without issuing an OPEN
again. The HOLD value is not available when there are non-<span class="keyword">iSeries</span> connections
that are not released for a program and SQL is still in the call stack. If
ALWBLK(*ALLREAD) and either COMMIT(*CHG) or COMMIT(*CS) are specified when
the program is precompiled, all read-only cursors will allow blocking of rows
and a ROLLBACK HOLD statement will not roll the cursor position back.</p>
</div>
<div class="section"><p>If there are locked rows (records) pending from running a SQL
precompiled program or an Interactive SQL session, a COMMIT or
ROLLBACK statement can be issued from the server Command Entry display. Otherwise,
an implicit ROLLBACK operation occurs when the job is ended.</p>
</div>
<div class="section"><p>You can use the <span class="cmdname">Work with Commitment Definitions (WRKCMTDFN)</span> command
to monitor the status of commitment definitions and free up locks and held
resources involved with commitment control activities across servers.</p>
</div>
<div class="tablenoborder"><a name="rbal1rcvtrn__rbal1reclock"><!-- --></a><table cellpadding="4" cellspacing="0" summary="" id="rbal1rcvtrn__rbal1reclock" width="100%" frame="border" border="1" rules="all"><caption>Table 1. Record lock duration</caption><thead align="left"><tr><th align="left" valign="bottom" width="19.19191919191919%" id="d0e166">SQL statement</th>
<th align="left" valign="bottom" width="19.94949494949495%" id="d0e168">COMMIT parameter</th>
<th align="left" valign="bottom" width="44.44444444444444%" id="d0e170">Duration of record locks</th>
<th align="left" valign="bottom" width="16.414141414141415%" id="d0e172">Lock type</th>
</tr>
</thead>
<tbody><tr><td align="left" valign="top" width="19.19191919191919%" headers="d0e166 ">SELECT INTO </td>
<td align="left" valign="top" width="19.94949494949495%" headers="d0e168 "> <p>*NONE<br />
*CHG<br />
*CS<br />
*ALL (See note 2)</p>
</td>
<td align="left" valign="top" width="44.44444444444444%" headers="d0e170 "> <p>No locks<br />
No locks<br />
Row locked when read and released<br />
From read until ROLLBACK or COMMIT</p>
</td>
<td align="left" valign="top" width="16.414141414141415%" headers="d0e172 "> <p> <br />
 <br />
READ<br />
READ</p>
</td>
</tr>
<tr><td align="left" valign="top" width="19.19191919191919%" headers="d0e166 ">FETCH (read-only cursor)</td>
<td align="left" valign="top" width="19.94949494949495%" headers="d0e168 "> <p>*NONE<br />
*CHG<br />
*CS<br />
*ALL (See note 2)</p>
</td>
<td align="left" valign="top" width="44.44444444444444%" headers="d0e170 "> <p>No locks<br />
No locks<br />
From read until the next FETCH<br />
From read until ROLLBACK or COMMIT</p>
</td>
<td align="left" valign="top" width="16.414141414141415%" headers="d0e172 "> <p> <br />
 <br />
READ<br />
READ</p>
</td>
</tr>
<tr><td align="left" valign="top" width="19.19191919191919%" headers="d0e166 ">FETCH (update or delete capable cursor) See
note 1</td>
<td align="left" valign="top" width="19.94949494949495%" headers="d0e168 "> <p>*NONE<br />
 <br />
 <br />
 <br />
*CHG<br />
 <br />
 <br />
 <br />
*CS<br />
 <br />
 <br />
 <br />
*ALL</p>
</td>
<td align="left" valign="top" width="44.44444444444444%" headers="d0e170 "> <p>When record not updated or deleted<br />
from read until next FETCH<br />
When record is updated or deleted<br />
from read until UPDATE or DELETE<br />
When record not updated or deleted<br />
from read until next FETCH<br />
When record is updated or deleted<br />
from read until UPDATE or DELETE<br />
When record not updated or deleted<br />
from read until next FETCH<br />
When record is updated or deleted<br />
from read until UPDATE or DELETE<br />
From read until ROLLBACK or COMMIT</p>
</td>
<td align="left" valign="top" width="16.414141414141415%" headers="d0e172 "> <p>UPDATE<br />
 <br />
 <br />
 <br />
UPDATE<br />
 <br />
 <br />
 <br />
UPDATE<br />
 <br />
 <br />
 <br />
UPDATE<sup>3</sup></p>
</td>
</tr>
<tr><td align="left" valign="top" width="19.19191919191919%" headers="d0e166 ">INSERT (target table)</td>
<td align="left" valign="top" width="19.94949494949495%" headers="d0e168 "> <p>*NONE<br />
*CHG<br />
*CS<br />
*ALL</p>
</td>
<td align="left" valign="top" width="44.44444444444444%" headers="d0e170 "> <p>No locks<br />
From insert until ROLLBACK or COMMIT<br />
From insert until ROLLBACK or COMMIT<br />
From insert until ROLLBACK or COMMIT</p>
</td>
<td align="left" valign="top" width="16.414141414141415%" headers="d0e172 "> <p> <br />
UPDATE<br />
UPDATE<br />
UPDATE<sup>4</sup></p>
</td>
</tr>
<tr><td align="left" valign="top" width="19.19191919191919%" headers="d0e166 ">INSERT (tables in subselect)</td>
<td align="left" valign="top" width="19.94949494949495%" headers="d0e168 "> <p>*NONE<br />
*CHG<br />
*CS<br />
*ALL</p>
</td>
<td align="left" valign="top" width="44.44444444444444%" headers="d0e170 "> <p>No locks<br />
No locks<br />
Each record locked while being read<br />
From read until ROLLBACK or COMMIT</p>
</td>
<td align="left" valign="top" width="16.414141414141415%" headers="d0e172 "> <p> <br />
 <br />
READ<br />
READ</p>
</td>
</tr>
<tr><td align="left" valign="top" width="19.19191919191919%" headers="d0e166 ">UPDATE (non-cursor)</td>
<td align="left" valign="top" width="19.94949494949495%" headers="d0e168 "> <p>*NONE<br />
*CHG<br />
*CS<br />
*ALL</p>
</td>
<td align="left" valign="top" width="44.44444444444444%" headers="d0e170 "> <p>Each record locked while being updated<br />
From read until ROLLBACK or COMMIT<br />
From read until ROLLBACK or COMMIT<br />
From read until ROLLBACK or COMMIT</p>
</td>
<td align="left" valign="top" width="16.414141414141415%" headers="d0e172 "> <p>UPDATE<br />
UPDATE<br />
UPDATE<br />
UPDATE</p>
</td>
</tr>
<tr><td align="left" valign="top" width="19.19191919191919%" headers="d0e166 ">DELETE (non-cursor)</td>
<td align="left" valign="top" width="19.94949494949495%" headers="d0e168 "> <p>*NONE<br />
*CHG<br />
*CS<br />
*ALL</p>
</td>
<td align="left" valign="top" width="44.44444444444444%" headers="d0e170 "> <p>Each record locked while being deleted<br />
From read until ROLLBACK or COMMIT<br />
From read until ROLLBACK or COMMIT<br />
From read until ROLLBACK or COMMIT</p>
</td>
<td align="left" valign="top" width="16.414141414141415%" headers="d0e172 "> <p>UPDATE<br />
UPDATE<br />
UPDATE<br />
UPDATE</p>
</td>
</tr>
<tr><td align="left" valign="top" width="19.19191919191919%" headers="d0e166 ">UPDATE (with cursor)</td>
<td align="left" valign="top" width="19.94949494949495%" headers="d0e168 "> <p>*NONE<br />
*CHG<br />
*CS<br />
*ALL</p>
</td>
<td align="left" valign="top" width="44.44444444444444%" headers="d0e170 "> <p>Lock released when record updated<br />
From read until ROLLBACK or COMMIT<br />
From read until ROLLBACK or COMMIT<br />
From read until ROLLBACK or COMMIT</p>
</td>
<td align="left" valign="top" width="16.414141414141415%" headers="d0e172 "> <p>UPDATE<br />
UPDATE<br />
UPDATE<br />
UPDATE</p>
</td>
</tr>
<tr><td align="left" valign="top" width="19.19191919191919%" headers="d0e166 ">DELETE (with cursor)</td>
<td align="left" valign="top" width="19.94949494949495%" headers="d0e168 "> <p>*NONE<br />
*CHG<br />
*CS<br />
*ALL</p>
</td>
<td align="left" valign="top" width="44.44444444444444%" headers="d0e170 "> <p>Lock released when record deleted<br />
From read until ROLLBACK or COMMIT<br />
From read until ROLLBACK or COMMIT<br />
From read until ROLLBACK or COMMIT</p>
</td>
<td align="left" valign="top" width="16.414141414141415%" headers="d0e172 "> <p>UPDATE<br />
UPDATE<br />
UPDATE<br />
UPDATE</p>
</td>
</tr>
<tr><td align="left" valign="top" width="19.19191919191919%" headers="d0e166 ">Subqueries (update or delete capable cursor
or UPDATE or DELETE non-cursor)</td>
<td align="left" valign="top" width="19.94949494949495%" headers="d0e168 "> <p>*NONE<br />
*CHG<br />
*CS<br />
*ALL (see note 2)</p>
</td>
<td align="left" valign="top" width="44.44444444444444%" headers="d0e170 "> <p>From read until next FETCH<br />
From read until next FETCH<br />
From read until next FETCH<br />
From read until ROLLBACK or COMMIT</p>
</td>
<td align="left" valign="top" width="16.414141414141415%" headers="d0e172 "> <p>READ<br />
READ<br />
READ<br />
READ</p>
</td>
</tr>
<tr><td align="left" valign="top" width="19.19191919191919%" headers="d0e166 ">Subqueries (read-only cursor or SELECT INTO)</td>
<td align="left" valign="top" width="19.94949494949495%" headers="d0e168 "> <p>*NONE<br />
*CHG<br />
*CS<br />
*ALL</p>
</td>
<td align="left" valign="top" width="44.44444444444444%" headers="d0e170 "> <p>No locks<br />
No locks<br />
Each record locked while being read<br />
From read until ROLLBACK or COMMIT</p>
</td>
<td align="left" valign="top" width="16.414141414141415%" headers="d0e172 "> <p> <br />
 <br />
READ<br />
READ</p>
</td>
</tr>
<tr><td colspan="4" align="left" valign="top" headers="d0e166 d0e168 d0e170 d0e172 "><div class="note"><span class="notetitle">Notes:</span> <ol><li>A cursor is open with UPDATE or DELETE capabilities if the result table
is not read-only (see description of DECLARE CURSOR) and if one of the following
items is true: <ul><li>The cursor is defined with a FOR UPDATE clause.</li>
<li>The cursor is defined without a FOR UPDATE, FOR FETCH ONLY, or ORDER BY
clause and the program contains at least one of the following items: <ul><li>Cursor UPDATE referring to the same cursor-name</li>
<li>Cursor DELETE referring to the same cursor-name</li>
<li>An EXECUTE or EXECUTE IMMEDIATE statement with ALWBLK(*READ) or ALWBLK(*NONE)
specified on the CRTSQL<em>xxx</em> command</li>
</ul>
</li>
</ul>
</li>
<li>A table or view can be locked exclusively in order to satisfy COMMIT(*ALL).
If a subselect is processed that includes a group by or union, or if the processing
of the query requires the use of a temporary result, an exclusive lock is
acquired to protect you from seeing uncommitted changes.</li>
<li>If the row is not updated or deleted, the lock is reduced to *READ.</li>
<li>An UPDATE lock on rows of the target table and a READ lock on the rows
of the subselect table.</li>
<li>A table or view can be locked exclusively in order to satisfy repeatable
read. Row locking is still done under repeatable read. The locks acquired
and their duration are identical to *ALL.</li>
</ol>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rbal1recovsupp.htm" title="Failures that can occur on a computer server are a server failure (when the entire server is not operating); a loss of the site due to fire, flood, or similar catastrophe; or the damage or loss of an object. For a distributed relational database, a failure on one server in the network prevents users across the entire network from accessing the relational database on that server.">Recovery support for a distributed relational database</a></div>
</div>
<div class="reltasks"><strong>Related tasks</strong><br />
<div><a href="rbal1cmt.htm" title="Use the Work with Commitment Definitions (WRKCMTDFN) command if you want to work with the commitment definitions on the server.">Work with commitment definitions in a distributed relational database</a></div>
</div>
<div class="relref"><strong>Related reference</strong><br />
<div><a href="rbal1saverestore.htm" title="Saving and restoring data and programs allows recovery from a program or server failure, exchange of information between servers, or storage of objects or data offline. A sound backup policy at each server in the distributed relational database network ensures that a server can be restored and made available to network users quickly in the event of a problem.">Save and restore processing for a distributed relational database</a></div>
</div>
<div class="relinfo"><strong>Related information</strong><br />
<div><a href="../db2/rbafzmsth2clcu.htm">DECLARE CURSOR</a></div>
<div><a href="../cl/strcmtctl.htm">Start Commitment Control (STRCMTCTL) command</a></div>
<div><a href="../rzakj/rzakjtrouble.htm">Troubleshoot transactions and commitment control</a></div>
<div><a href="../cl/wrkcmtdfn.htm">Work with Commitment Definitions (WRKCMTDFN) command</a></div>
<div><a href="../cl/savobj.htm">Save Object (SAVOBJ) command</a></div>
<div><a href="../cl/savlib.htm">Save Library (SAVLIB) command</a></div>
<div><a href="../cl/savchgobj.htm">Save Changed Object (SAVCHGOBJ) command</a></div>
<div><a href="../cl/savsavfdta.htm">Save Save File Data (SAVSAVFDTA) command</a></div>
<div><a href="../cl/savsys.htm">Save System (SAVSYS) command</a></div>
<div><a href="../cl/rstlib.htm">Restore Library (RSTLIB) command</a></div>
<div><a href="../cl/rstobj.htm">Restore Object (RSTOBJ) command</a></div>
<div><a href="../cl/rstusrprf.htm">Restore User Profiles (RSTUSRPRF) command</a></div>
<div><a href="../cl/rstaut.htm">Restore Authority (RSTAUT) command</a></div>
<div><a href="../cl/rstcfg.htm">Restore Configuration (RSTCFG) command</a></div>
</div>
</div>
</body>
</html>