Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1745461
  • 博文数量: 335
  • 博客积分: 4690
  • 博客等级: 上校
  • 技术积分: 4341
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-08 21:38
个人简介

无聊之人--除了技术,还是技术,你懂得

文章分类

全部博文(335)

文章存档

2016年(29)

2015年(18)

2014年(7)

2013年(86)

2012年(90)

2011年(105)

分类: DB2/Informix

2012-12-24 23:28:12

DB2 使用claim & drain来控制SQL 与utility对数据库对象的访问。
claim说明有对象正在访问或是将要访问该对象
而drain则是在对象上面加一个drain lock,等所有的claimers执行完成以后,对该对象进行特定的处理操作。drain lock的目的是防止多个process同时drain一个对象,从而出现drain deadlock。
二者都是对象级别的,它独立于事务锁而存在。
需要注意的drain是action,即它也是一个claim,它发出drain的指令,拿到drain lock,然后就等待其他的claimers执行完成,然后执行自己的drained  claim

 Claims and drains for concurrency control
Claims and drains are taken at the object level only and not at the page or row level. DB2
utilities, commands, and some ALTER, CREATE, and DROP statements can take over
access to some DB2 objects independent of any transaction locks that are held on the object.
Claims and drains on an index
Unlike transaction locks, the claims and drains can be taken on indexes also. DB2 utilities,
commands, and some ALTER, CREATE, and DROP statements can take over access to
certain objects.
The following objects are subject to takeover by those operations:
 Simple and segmented table spaces
 Partitions of table spaces
 LOB table spaces
 XML table spaces
 Non-partitioned index spaces
 Partitions of index spaces
 Logical partitions of non-partitioned indexes

A claim is a notification to DB2 that an object is being accessed.
When an application first accesses an object, within a unit of work, it makes a claim on the
object. It releases the claim at the next commit point. Unlike a transaction lock, a claim
normally does not persist past the commit point. To access the object in the next unit of work,
the application must make a new claim.
However, an exception exists: If a cursor defined with the WITH HOLD clause is positioned on
the claimed object, the claim is not released at a commit point.
A claim indicates activity on or interest in a particular page set or partition to DB2. Claims
prevent drains from occurring until the claim is released.
Three classes of claims
Table 6-1 shows the three classes of claims and the actions that they allow.
Table 6-1 Claim classes and how DB2 uses them
Claim class Notification to DB2 that the following action is being performed on
the object involved
Write Reading, updating, inserting, and deleting
Repeatable read Reading only, with repeatable read (RR) isolation
Cursor stability read Reading only, with read stability (RS), cursor stability (CS), or uncommitted
read (UR) isolation
A drain is the action of taking over access to an object by preventing new claims and waiting
for existing claims to be released.
A utility can drain a partition when applications are accessing it. The drain quiesces the
applications by allowing each one to reach a commit point, but preventing any of them, or any
other applications, from making a new claim. When no more claims exist, the process that
drains (the drainer) controls access to the drained object. The applications that were drained
can still hold transaction locks on the drained object, but they cannot make new claims until
the drainer has finished.
Drained claim classes
A drainer does not always need complete control. It could drain the following combinations of
claim classes:
 Only the write claim class
 Only the repeatable read claim class
 All claim classes
For example, the CHECK INDEX utility needs to drain only writers from an index space and
its associated table space. The RECOVER TABLESPACE utility, however, must drain all claim
classes from its table space. The REORG utility can drain either writers (with DRAIN
WRITERS) or all claim classes (with DRAIN ALL).
How DB2 uses drain locks
A drain lock prevents conflicting processes from trying to drain the same object at the same
time.
Processes that drain only writers can run concurrently, but a process that drains all claim
classes cannot drain an object concurrently with any other process. To drain an object, a
drainer first acquires one or more drain locks on the object, one for each claim class that it
needs to drain. When the locks are in place, the drainer can begin after all processes with
claims on the object have released their claims. A drain lock also prevents new claimers from
accessing an object while a drainer has control of it.
Types of drain locks
Three types of drain locks on an object correspond to the three claim classes:
 Write
 Repeatable read
 Cursor stability read
In general, after an initial claim has been made on an object by a user, no other user in the
system needs a drain lock. When the drain lock is granted, no drains on the object are in
process for the claim class needed, and the claimer can proceed.
The claimer of an object requests a drain lock in the following exceptional case: The claim is
the first claim on an object before its data set has been physically opened. Here, acquiring the
drain lock ensures that no exception states prohibit allocating the data set.
For data sharing, when the claimer gets the drain lock, it makes its claim and releases the
lock before beginning its processing.
阅读(2617) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~