Data Concurrency and Consistency-Introduction to Data Concurrency and Consistency

来源:互联网 发布:flash游戏制作软件 编辑:程序博客网 时间:2024/05/17 07:12

Data Concurrency:确保用户能够同时访问数据。

Data Consistency:确保每个用户看到数据的一致性视图,包括用户自己对数据库的改变和其他用户commit之后的数据。

Oracle Database maintains data consistency by using a multiversion consistency model and various types oflocks andtransactions

1、Mulitversion Read Consistency

Oracle Database maintains multiversion read consistency, which means that database queries have the following characteristics:

a、Read-consistent queries

查询返回的数据是已经提交过的,并且和某个时间点的数据是一致的。

Oracle database不允许dirty reads,dirty read发生在一个transaction读取了另一个transaction未提交的数据。

b、Nonblocking queryies

Readers and writers of data do not block one another。

1.1Statement-Level Read Consistency(语句级读一致性)

Oracle Database always enforces statement-level read consistency.

  • In the read committed isolation level, this point is the time at which the statement was opened. For example, if a SELECT statement opens at SCN 1000, then this statement is consistent to SCN 1000.

  • In a serializable or read-only transaction this point is the time the transaction began. For example, if a transaction begins at SCN 1000, and if multipleSELECT statements occur in this transaction, then each statement is consistent to SCN 1000.

  • In a Flashback Query operation (SELECT ... AS OF), the SELECT statement explicitly specifies the point in time. For example, you can query a table as it appeared last Thursday at 2 p.m.

1.2Transaction-Level Read Consistency(事务级读一致性)

Oracle Database can also provide read consistency to all queries in a transaction, known as transaction-level read consistency. In this case, each statement in a transaction sees data from the same point in time, which is the time at which the transaction began.

Queries made by a serializable transaction see changes made by the transaction itself. For example, a transaction that updates employees and then queriesemployees will see the updates. Transaction-level read consistency 不会产生幻读。

1.3Read Consistency and Undo Segments

当一个表同时被查询和更新的时候,数据库create a read-consistent set of data来管理多版本读一致性。Oracle Database achieves this goal through undo data.

当用户改变数据的时候,数据库创建undo entries(这些数据被写入undo segments)。The undo segments contain the old values of data that have been changed by uncommitted or recently committed transactions. 

Read consistency is guaranteed in single-instance and Oracle Real Application Clusters (Oracle RAC) environments. Oracle RAC uses a cache-to-cache block transfer mechanism known as Cache Fusion to transfer read-consistent images of data blocks from one database instance to another.


0 0
原创粉丝点击