Rac 的GES/GCS原理(3)

9 篇文章 0 订阅

Lock Types
Every lock has a type,which is a two character alphabetic identifier(e.g ,BL,CU,SE,NB).The number of lock types
varies with each release.Some lock types are only used in RDBMS instances,others in ASM instances,and the reminder
are used in both.
每一种锁都有个类型,它是一个两字母的标识符(e.g BL,CU,SE,NB). 每种锁类型的个数因为数据库的版本而不同。某些类型的锁仅仅用在RDBMS 实例中,某些在ASM 实例中,其它剩下的在两种实例中都有。

Each lock type has two parameters ,which are called tags.Each tag value is a 32-bit number.The tag values differ
according to the lock type,but the name and the two tag values form a unique identifier for the lock.For example,
for a library cache object LB lock,the parameters represent a portion of the hash value for the object,which is
derived from the object name.On the other hand,for a TM lock,the first parameter contains the object number,and the
second parameter describes whether the object is a table or a partition.

每种锁类型都有2个参数,它们被叫做标签。每个标签值为一个32位的数字。标签的数值因为锁类型的不同而不同,它们的格式一般如下,名字以及两标签的数值形成了锁类型的唯一标识符。比如说,对于一个library cache 对象 LB 锁,这个参数代表了对象hash 数值的一部分,他来自于对象名。另一方面,针对一个TM锁,第一个参数包含了对象号,第二个参数代表对象是一个表还是一个分区。

In oracle 10.1 and above ,the V$LOCK_TYPE dynamic performance view summarizes all implemented lock types.
在oracle 10.1 以及以上版本中,v$LOCK_TYPE 动态视图 概括了所有的 当前锁类型。
Some lock types ,for example ,The Tx transaction lock and the CU cursor lock,only affect the local instance;
therefore ,they can be managed locally.Other lock types,such as the TM table lock and the all library cache locks
and pins,must be observed by all instances in the database; therefore ,they must be managed globally.

某些锁类型,比如说,TX 事务锁和CU 游标锁,仅仅影响本地实例;因此,它们可以被本地管理。其它的锁类型,比如TM 表锁和 所有的library cache锁和pins,必须被数据库中所有的实例来观察;因此,它们必须被全局来管理。

The most common lock types seen in a RAC database are listed in Table 22-1.
Common Lock Types
Type      Description
BL        Block(GCS)
CU        Cursor lock
HW        High water mark lock
L*        Library cache lock
N*        Library cache pin
Q*        Dictionary cache lock
SQ        Sequence cache
TM        Table lock
TS        Temporary segment
TT        Tablespace lock(for DDL)
TX        Transaction lock


library cache locks

Each RAC instance has its own library cache.The library cache contains all statemets ad packages currently in use by
the instance.In addition ,the library cache contains all objects that are referenced by these statements and packages.
每个RAC下的实例都有它自己的library cache。Library cache 包含了所有被当前实例所使用的包以及语句。而且,library cache 包含了所有被这些语句和包引用到的对象。

When a DML or DDL statement is parsed,all database objects that are referenced by that statement are locked using a library
cache lock for the duration of the parse call.These objects include tables ,indexes,views,packages,procedures,and functions.
Referenced objects are also locked in the library cache during the compliation of all PL/SQL packages and Java classes.
当一个DML或DDL操作被解析的时候,所有被引用的数据库对象将被锁定,使用的是library cache锁,指导这个语句分析结束,这个锁才会被释放。这些对象包含有 表,索引,视图,包,存储过程和函数。被引用的对象在 PL/SQL 和JAVA类被编译的过程中,也是被锁定在library cache里的。


When a statement is executed,all referenced objects are locked briefly to allow them to be pinned.Objects are pinned
during statement execution to prevent modification of them by other processes ,such as  those executing DDL statements.
当一个语句被执行的时候,所有它涉及到的对象将被很快的锁定,并允许它们被pin操作读取。在这个语句执行的时候,这些对象被pin住了,
防止被其他进程所访问,比如哪些执行DDL 语句的情况。


Namespaces
Every objects in the library cache belongs to a namespace.The number of namespaces is release dependent;in Oracle 10.2
there can be a maximum of 64,although not all are used in that release.
Library cache中的每个对象都属于一个 namespace. namespace的个数是根据版本的,在ORACLE 10.2 版本里,最多可以有64个namespace,尽管不是所有的namespace都被使用。
Within a namespace,each object name must be unique.For example,one of the namespaces is called TABL/PRCD/TYPE,which
ensures that no table ,procedure,or user-defined type can have the same name.
在一个namespace中,每个对象都必须唯一。比如说,有一个namespace叫做 TABL/PRCD/TYPE,可以保证 表、存储过程、用户定义的类型不能同名。

The namespace for each object is externalized as a number in the KGLHDNSP column of the X$KGLOB family of views.
You can obtain limited statistics for objects in the library cache,such as the number of gets and pins from the
V$LIBRARYCACHE view.Note,however,that this view returns only a subset of namespaces from the x$KGLST base view.
命名空间对应了 X$KGLOB 家族视图中 KGLHDNSP列的一个数字。你可以获得library cache中对象的 有限的信息,比如说从
v$librarycache视图中 gets 和 pins的个数。请注意,这个视图仅仅返回命名空间x$KGLST 基本视图的子集。
Prior to Oracle10g,you could also identify the namespace for each object from a libary cache dump as follows:
SQL>Alter session set events 'immediate trace name library_cache level 8';

In this dump,each object in the library cache has a namespace attribute.Unfortunantely in Oracle 10.1 and 10.2,
this attribute has become confused with the object type,which is externalized as KGLOBTYP in the X$KGLOB
family of views.Although the namespace attribute is incorrect in the dump.you can still determine the true
namespace by inspecting the instance lock types for the library cache locks and pins as described later in
this section.
在这个dump里面,每个library cache里的对象都有一个命名空间属性。不幸的是在Oracle 10.1和 10.2 ,这个属性和对象类型容易混淆,对象类型在X$KGLST 家族视图的KGLOBTYP列中可以找到。 虽然在dump文件里 命名空间属性是不正确的,你仍然可以从查看实例锁类型来决定真正的命名空间,这个将在这个章节的后面介绍这些实例锁(针对library cache locks 和 pins 的)。


Hash Values
Every object in the library cache has a hash value.This is derived from a combination of the namespace and a
name.In the case of stored objects ,such as tables,the name is derived from the owner name,object name,and
optionally,a remote link.In the case of transient objects,such as SQL statements,the name is derived from
the text of the SQL statement.
Library cache里面的每个对象都有一个hash数值。这个数值从命名空间和对象名的集合获得。对一个储存的对象来说,比如表,
它的hash名是从对象属主名、对象名,还有可选的,从远程链接名获得。针对一个临时对象,比如SQL语句,它的hash 名是从
SQL 语句的文字获得的。

Prior to Oracle 10.1,the hash value was represented by  a 32-bit number,which is still calculated and
externalized in the KGLNAHSH  column of X$KGLOB.This 32-bit hash value was sufficient for most purposes,
but could ,on occasion,lead to collisions.Therefor,in Oracle 10.1 and above,a new hash value is calculated
using a 128-bit value,which more or less guarantees uniqueness.This new value is externalized in the
KGLNAHSV column of X$KGLOB.

在10.1版本前,hash数值是一个32位的数字,它将被计算之后在 X$KGLOB 视图的 KGLNAHSH 列上表示出来。针对绝大多数情况,这个32位的 hash数值对绝大多数情况来说是足够了。不过在某些情况下,将导致冲突。因此,在ORACLE 10.1 以及以上版本,将使用128位数值value,这或多或少保证了唯一性。这个新的数值可以通过查看 X$KGLOB 的 KGLNAHSV列来得到。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值